Debian Codegraph @

internal/integration/reql_tests/reql_math_logic_math_test.go

raw symbols SCIP
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 // Tests of nested arithmetic expressions
17 func TestMathLogicMathSuite(t *testing.T) {
18 suite.Run(t, new(MathLogicMathSuite))
19 }
20
21 type MathLogicMathSuite struct {
22 suite.Suite
23
24 session *r.Session
25 }
26
27 func (suite *MathLogicMathSuite) SetupTest() {
28 suite.T().Log("Setting up MathLogicMathSuite")
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("db_logic_math").Exec(suite.session)
40 err = r.DBCreate("db_logic_math").Exec(suite.session)
41 suite.Require().NoError(err)
42 err = r.DB("db_logic_math").Wait().Exec(suite.session)
43 suite.Require().NoError(err)
44
45 }
46
47 func (suite *MathLogicMathSuite) TearDownSuite() {
48 suite.T().Log("Tearing down MathLogicMathSuite")
49
50 if suite.session != nil {
51 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
52 r.DBDrop("db_logic_math").Exec(suite.session)
53
54 suite.session.Close()
55 }
56 }
57
58 func (suite *MathLogicMathSuite) TestCases() {
59 suite.T().Log("Running MathLogicMathSuite: Tests of nested arithmetic expressions")
60
61 {
62 // math_logic/math.yaml line #4
63 /* 1 */
64 var expected_ int = 1
65 /* (((4 + 2 * (r.expr(26) % 18)) / 5) - 3) */
66
67 suite.T().Log("About to run line #4: r.Add(4, r.Mul(2, r.Expr(26).Mod(18))).Div(5).Sub(3)")
68
69 runAndAssert(suite.Suite, expected_, r.Add(4, r.Mul(2, r.Expr(26).Mod(18))).Div(5).Sub(3), suite.session, r.RunOpts{
70 GeometryFormat: "raw",
71 GroupFormat: "map",
72 })
73 suite.T().Log("Finished running line #4")
74 }
75 }