gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/internal/integration/reql_tests/reql_math_logic_aliases_test.go (about)

     1  // Code generated by gen_tests.py and process_polyglot.py.
     2  // Do not edit this file directly.
     3  // The template for this file is located at:
     4  // ../template.go.tpl
     5  package reql_tests
     6  
     7  import (
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/stretchr/testify/suite"
    12  	r "gopkg.in/rethinkdb/rethinkdb-go.v6"
    13  	"gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare"
    14  )
    15  
    16  // Test named aliases for math and logic operators
    17  func TestMathLogicAliasesSuite(t *testing.T) {
    18  	suite.Run(t, new(MathLogicAliasesSuite))
    19  }
    20  
    21  type MathLogicAliasesSuite struct {
    22  	suite.Suite
    23  
    24  	session *r.Session
    25  }
    26  
    27  func (suite *MathLogicAliasesSuite) SetupTest() {
    28  	suite.T().Log("Setting up MathLogicAliasesSuite")
    29  	// Use imports to prevent errors
    30  	_ = time.Time{}
    31  	_ = compare.AnythingIsFine
    32  
    33  	session, err := r.Connect(r.ConnectOpts{
    34  		Address: url,
    35  	})
    36  	suite.Require().NoError(err, "Error returned when connecting to server")
    37  	suite.session = session
    38  
    39  	r.DBDrop("test").Exec(suite.session)
    40  	err = r.DBCreate("test").Exec(suite.session)
    41  	suite.Require().NoError(err)
    42  	err = r.DB("test").Wait().Exec(suite.session)
    43  	suite.Require().NoError(err)
    44  
    45  }
    46  
    47  func (suite *MathLogicAliasesSuite) TearDownSuite() {
    48  	suite.T().Log("Tearing down MathLogicAliasesSuite")
    49  
    50  	if suite.session != nil {
    51  		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
    52  		r.DBDrop("test").Exec(suite.session)
    53  
    54  		suite.session.Close()
    55  	}
    56  }
    57  
    58  func (suite *MathLogicAliasesSuite) TestCases() {
    59  	suite.T().Log("Running MathLogicAliasesSuite: Test named aliases for math and logic operators")
    60  
    61  	{
    62  		// math_logic/aliases.yaml line #5
    63  		/* 1 */
    64  		var expected_ int = 1
    65  		/* r.expr(0).add(1) */
    66  
    67  		suite.T().Log("About to run line #5: r.Expr(0).Add(1)")
    68  
    69  		runAndAssert(suite.Suite, expected_, r.Expr(0).Add(1), suite.session, r.RunOpts{
    70  			GeometryFormat: "raw",
    71  			GroupFormat:    "map",
    72  		})
    73  		suite.T().Log("Finished running line #5")
    74  	}
    75  
    76  	{
    77  		// math_logic/aliases.yaml line #6
    78  		/* 1 */
    79  		var expected_ int = 1
    80  		/* r.add(0, 1) */
    81  
    82  		suite.T().Log("About to run line #6: r.Add(0, 1)")
    83  
    84  		runAndAssert(suite.Suite, expected_, r.Add(0, 1), suite.session, r.RunOpts{
    85  			GeometryFormat: "raw",
    86  			GroupFormat:    "map",
    87  		})
    88  		suite.T().Log("Finished running line #6")
    89  	}
    90  
    91  	{
    92  		// math_logic/aliases.yaml line #7
    93  		/* 1 */
    94  		var expected_ int = 1
    95  		/* r.expr(2).sub(1) */
    96  
    97  		suite.T().Log("About to run line #7: r.Expr(2).Sub(1)")
    98  
    99  		runAndAssert(suite.Suite, expected_, r.Expr(2).Sub(1), suite.session, r.RunOpts{
   100  			GeometryFormat: "raw",
   101  			GroupFormat:    "map",
   102  		})
   103  		suite.T().Log("Finished running line #7")
   104  	}
   105  
   106  	{
   107  		// math_logic/aliases.yaml line #8
   108  		/* 1 */
   109  		var expected_ int = 1
   110  		/* r.sub(2, 1) */
   111  
   112  		suite.T().Log("About to run line #8: r.Sub(2, 1)")
   113  
   114  		runAndAssert(suite.Suite, expected_, r.Sub(2, 1), suite.session, r.RunOpts{
   115  			GeometryFormat: "raw",
   116  			GroupFormat:    "map",
   117  		})
   118  		suite.T().Log("Finished running line #8")
   119  	}
   120  
   121  	{
   122  		// math_logic/aliases.yaml line #9
   123  		/* 1 */
   124  		var expected_ int = 1
   125  		/* r.expr(2).div(2) */
   126  
   127  		suite.T().Log("About to run line #9: r.Expr(2).Div(2)")
   128  
   129  		runAndAssert(suite.Suite, expected_, r.Expr(2).Div(2), suite.session, r.RunOpts{
   130  			GeometryFormat: "raw",
   131  			GroupFormat:    "map",
   132  		})
   133  		suite.T().Log("Finished running line #9")
   134  	}
   135  
   136  	{
   137  		// math_logic/aliases.yaml line #10
   138  		/* 1 */
   139  		var expected_ int = 1
   140  		/* r.div(2, 2) */
   141  
   142  		suite.T().Log("About to run line #10: r.Div(2, 2)")
   143  
   144  		runAndAssert(suite.Suite, expected_, r.Div(2, 2), suite.session, r.RunOpts{
   145  			GeometryFormat: "raw",
   146  			GroupFormat:    "map",
   147  		})
   148  		suite.T().Log("Finished running line #10")
   149  	}
   150  
   151  	{
   152  		// math_logic/aliases.yaml line #11
   153  		/* 1 */
   154  		var expected_ int = 1
   155  		/* r.expr(1).mul(1) */
   156  
   157  		suite.T().Log("About to run line #11: r.Expr(1).Mul(1)")
   158  
   159  		runAndAssert(suite.Suite, expected_, r.Expr(1).Mul(1), suite.session, r.RunOpts{
   160  			GeometryFormat: "raw",
   161  			GroupFormat:    "map",
   162  		})
   163  		suite.T().Log("Finished running line #11")
   164  	}
   165  
   166  	{
   167  		// math_logic/aliases.yaml line #12
   168  		/* 1 */
   169  		var expected_ int = 1
   170  		/* r.mul(1, 1) */
   171  
   172  		suite.T().Log("About to run line #12: r.Mul(1, 1)")
   173  
   174  		runAndAssert(suite.Suite, expected_, r.Mul(1, 1), suite.session, r.RunOpts{
   175  			GeometryFormat: "raw",
   176  			GroupFormat:    "map",
   177  		})
   178  		suite.T().Log("Finished running line #12")
   179  	}
   180  
   181  	{
   182  		// math_logic/aliases.yaml line #13
   183  		/* 1 */
   184  		var expected_ int = 1
   185  		/* r.expr(1).mod(2) */
   186  
   187  		suite.T().Log("About to run line #13: r.Expr(1).Mod(2)")
   188  
   189  		runAndAssert(suite.Suite, expected_, r.Expr(1).Mod(2), suite.session, r.RunOpts{
   190  			GeometryFormat: "raw",
   191  			GroupFormat:    "map",
   192  		})
   193  		suite.T().Log("Finished running line #13")
   194  	}
   195  
   196  	{
   197  		// math_logic/aliases.yaml line #14
   198  		/* 1 */
   199  		var expected_ int = 1
   200  		/* r.mod(1, 2) */
   201  
   202  		suite.T().Log("About to run line #14: r.Mod(1, 2)")
   203  
   204  		runAndAssert(suite.Suite, expected_, r.Mod(1, 2), suite.session, r.RunOpts{
   205  			GeometryFormat: "raw",
   206  			GroupFormat:    "map",
   207  		})
   208  		suite.T().Log("Finished running line #14")
   209  	}
   210  
   211  	{
   212  		// math_logic/aliases.yaml line #25
   213  		/* True */
   214  		var expected_ bool = true
   215  		/* r.expr(True).and_(True) */
   216  
   217  		suite.T().Log("About to run line #25: r.Expr(true).And(true)")
   218  
   219  		runAndAssert(suite.Suite, expected_, r.Expr(true).And(true), suite.session, r.RunOpts{
   220  			GeometryFormat: "raw",
   221  			GroupFormat:    "map",
   222  		})
   223  		suite.T().Log("Finished running line #25")
   224  	}
   225  
   226  	{
   227  		// math_logic/aliases.yaml line #26
   228  		/* True */
   229  		var expected_ bool = true
   230  		/* r.expr(True).or_(True) */
   231  
   232  		suite.T().Log("About to run line #26: r.Expr(true).Or(true)")
   233  
   234  		runAndAssert(suite.Suite, expected_, r.Expr(true).Or(true), suite.session, r.RunOpts{
   235  			GeometryFormat: "raw",
   236  			GroupFormat:    "map",
   237  		})
   238  		suite.T().Log("Finished running line #26")
   239  	}
   240  
   241  	{
   242  		// math_logic/aliases.yaml line #27
   243  		/* True */
   244  		var expected_ bool = true
   245  		/* r.and_(True, True) */
   246  
   247  		suite.T().Log("About to run line #27: r.And(true, true)")
   248  
   249  		runAndAssert(suite.Suite, expected_, r.And(true, true), suite.session, r.RunOpts{
   250  			GeometryFormat: "raw",
   251  			GroupFormat:    "map",
   252  		})
   253  		suite.T().Log("Finished running line #27")
   254  	}
   255  
   256  	{
   257  		// math_logic/aliases.yaml line #28
   258  		/* True */
   259  		var expected_ bool = true
   260  		/* r.or_(True, True) */
   261  
   262  		suite.T().Log("About to run line #28: r.Or(true, true)")
   263  
   264  		runAndAssert(suite.Suite, expected_, r.Or(true, true), suite.session, r.RunOpts{
   265  			GeometryFormat: "raw",
   266  			GroupFormat:    "map",
   267  		})
   268  		suite.T().Log("Finished running line #28")
   269  	}
   270  
   271  	{
   272  		// math_logic/aliases.yaml line #29
   273  		/* True */
   274  		var expected_ bool = true
   275  		/* r.expr(False).not_() */
   276  
   277  		suite.T().Log("About to run line #29: r.Expr(false).Not()")
   278  
   279  		runAndAssert(suite.Suite, expected_, r.Expr(false).Not(), suite.session, r.RunOpts{
   280  			GeometryFormat: "raw",
   281  			GroupFormat:    "map",
   282  		})
   283  		suite.T().Log("Finished running line #29")
   284  	}
   285  
   286  	{
   287  		// math_logic/aliases.yaml line #30
   288  		/* True */
   289  		var expected_ bool = true
   290  		/* r.not_(False) */
   291  
   292  		suite.T().Log("About to run line #30: r.Not(false)")
   293  
   294  		runAndAssert(suite.Suite, expected_, r.Not(false), suite.session, r.RunOpts{
   295  			GeometryFormat: "raw",
   296  			GroupFormat:    "map",
   297  		})
   298  		suite.T().Log("Finished running line #30")
   299  	}
   300  
   301  	{
   302  		// math_logic/aliases.yaml line #34
   303  		/* True */
   304  		var expected_ bool = true
   305  		/* r.expr(1).eq(1) */
   306  
   307  		suite.T().Log("About to run line #34: r.Expr(1).Eq(1)")
   308  
   309  		runAndAssert(suite.Suite, expected_, r.Expr(1).Eq(1), suite.session, r.RunOpts{
   310  			GeometryFormat: "raw",
   311  			GroupFormat:    "map",
   312  		})
   313  		suite.T().Log("Finished running line #34")
   314  	}
   315  
   316  	{
   317  		// math_logic/aliases.yaml line #35
   318  		/* True */
   319  		var expected_ bool = true
   320  		/* r.expr(1).ne(2) */
   321  
   322  		suite.T().Log("About to run line #35: r.Expr(1).Ne(2)")
   323  
   324  		runAndAssert(suite.Suite, expected_, r.Expr(1).Ne(2), suite.session, r.RunOpts{
   325  			GeometryFormat: "raw",
   326  			GroupFormat:    "map",
   327  		})
   328  		suite.T().Log("Finished running line #35")
   329  	}
   330  
   331  	{
   332  		// math_logic/aliases.yaml line #36
   333  		/* True */
   334  		var expected_ bool = true
   335  		/* r.expr(1).lt(2) */
   336  
   337  		suite.T().Log("About to run line #36: r.Expr(1).Lt(2)")
   338  
   339  		runAndAssert(suite.Suite, expected_, r.Expr(1).Lt(2), suite.session, r.RunOpts{
   340  			GeometryFormat: "raw",
   341  			GroupFormat:    "map",
   342  		})
   343  		suite.T().Log("Finished running line #36")
   344  	}
   345  
   346  	{
   347  		// math_logic/aliases.yaml line #37
   348  		/* True */
   349  		var expected_ bool = true
   350  		/* r.expr(1).gt(0) */
   351  
   352  		suite.T().Log("About to run line #37: r.Expr(1).Gt(0)")
   353  
   354  		runAndAssert(suite.Suite, expected_, r.Expr(1).Gt(0), suite.session, r.RunOpts{
   355  			GeometryFormat: "raw",
   356  			GroupFormat:    "map",
   357  		})
   358  		suite.T().Log("Finished running line #37")
   359  	}
   360  
   361  	{
   362  		// math_logic/aliases.yaml line #38
   363  		/* True */
   364  		var expected_ bool = true
   365  		/* r.expr(1).le(1) */
   366  
   367  		suite.T().Log("About to run line #38: r.Expr(1).Le(1)")
   368  
   369  		runAndAssert(suite.Suite, expected_, r.Expr(1).Le(1), suite.session, r.RunOpts{
   370  			GeometryFormat: "raw",
   371  			GroupFormat:    "map",
   372  		})
   373  		suite.T().Log("Finished running line #38")
   374  	}
   375  
   376  	{
   377  		// math_logic/aliases.yaml line #39
   378  		/* True */
   379  		var expected_ bool = true
   380  		/* r.expr(1).ge(1) */
   381  
   382  		suite.T().Log("About to run line #39: r.Expr(1).Ge(1)")
   383  
   384  		runAndAssert(suite.Suite, expected_, r.Expr(1).Ge(1), suite.session, r.RunOpts{
   385  			GeometryFormat: "raw",
   386  			GroupFormat:    "map",
   387  		})
   388  		suite.T().Log("Finished running line #39")
   389  	}
   390  
   391  	{
   392  		// math_logic/aliases.yaml line #40
   393  		/* True */
   394  		var expected_ bool = true
   395  		/* r.eq(1, 1) */
   396  
   397  		suite.T().Log("About to run line #40: r.Eq(1, 1)")
   398  
   399  		runAndAssert(suite.Suite, expected_, r.Eq(1, 1), suite.session, r.RunOpts{
   400  			GeometryFormat: "raw",
   401  			GroupFormat:    "map",
   402  		})
   403  		suite.T().Log("Finished running line #40")
   404  	}
   405  
   406  	{
   407  		// math_logic/aliases.yaml line #41
   408  		/* True */
   409  		var expected_ bool = true
   410  		/* r.ne(1, 2) */
   411  
   412  		suite.T().Log("About to run line #41: r.Ne(1, 2)")
   413  
   414  		runAndAssert(suite.Suite, expected_, r.Ne(1, 2), suite.session, r.RunOpts{
   415  			GeometryFormat: "raw",
   416  			GroupFormat:    "map",
   417  		})
   418  		suite.T().Log("Finished running line #41")
   419  	}
   420  
   421  	{
   422  		// math_logic/aliases.yaml line #42
   423  		/* True */
   424  		var expected_ bool = true
   425  		/* r.lt(1, 2) */
   426  
   427  		suite.T().Log("About to run line #42: r.Lt(1, 2)")
   428  
   429  		runAndAssert(suite.Suite, expected_, r.Lt(1, 2), suite.session, r.RunOpts{
   430  			GeometryFormat: "raw",
   431  			GroupFormat:    "map",
   432  		})
   433  		suite.T().Log("Finished running line #42")
   434  	}
   435  
   436  	{
   437  		// math_logic/aliases.yaml line #43
   438  		/* True */
   439  		var expected_ bool = true
   440  		/* r.gt(1, 0) */
   441  
   442  		suite.T().Log("About to run line #43: r.Gt(1, 0)")
   443  
   444  		runAndAssert(suite.Suite, expected_, r.Gt(1, 0), suite.session, r.RunOpts{
   445  			GeometryFormat: "raw",
   446  			GroupFormat:    "map",
   447  		})
   448  		suite.T().Log("Finished running line #43")
   449  	}
   450  
   451  	{
   452  		// math_logic/aliases.yaml line #44
   453  		/* True */
   454  		var expected_ bool = true
   455  		/* r.le(1, 1) */
   456  
   457  		suite.T().Log("About to run line #44: r.Le(1, 1)")
   458  
   459  		runAndAssert(suite.Suite, expected_, r.Le(1, 1), suite.session, r.RunOpts{
   460  			GeometryFormat: "raw",
   461  			GroupFormat:    "map",
   462  		})
   463  		suite.T().Log("Finished running line #44")
   464  	}
   465  
   466  	{
   467  		// math_logic/aliases.yaml line #45
   468  		/* True */
   469  		var expected_ bool = true
   470  		/* r.ge(1, 1) */
   471  
   472  		suite.T().Log("About to run line #45: r.Ge(1, 1)")
   473  
   474  		runAndAssert(suite.Suite, expected_, r.Ge(1, 1), suite.session, r.RunOpts{
   475  			GeometryFormat: "raw",
   476  			GroupFormat:    "map",
   477  		})
   478  		suite.T().Log("Finished running line #45")
   479  	}
   480  }