当前位置: 首页>>代码示例>>Golang>>正文


Golang v2.Expr函数代码示例

本文整理汇总了Golang中gopkg/in/dancannon/gorethink/v2.Expr函数的典型用法代码示例。如果您正苦于以下问题:Golang Expr函数的具体用法?Golang Expr怎么用?Golang Expr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Expr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestCases

func (suite *MetaCompositeSuite) TestCases() {
	suite.T().Log("Running MetaCompositeSuite: Tests meta operations in composite queries")

	{
		// meta/composite.py.yaml line #4
		/* ({'dbs_created':3,'config_changes':arrlen(3)}) */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dbs_created": 3, "config_changes": arrlen(3)}
		/* r.expr([1,2,3]).for_each(r.db_create('db_' + r.row.coerce_to('string'))) */

		suite.T().Log("About to run line #4: r.Expr([]interface{}{1, 2, 3}).ForEach(r.DBCreate(r.Add('db_', r.Row.CoerceTo('string'))))")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(r.DBCreate(r.Add("db_", r.Row.CoerceTo("string")))), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #4")
	}

	{
		// meta/composite.py.yaml line #8
		/* partial({'tables_created':9}) */
		var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 9})
		/* r.db_list().set_difference(["rethinkdb", "test"]).for_each(lambda db_name:
		r.expr([1,2,3]).for_each(lambda i:
		r.db(db_name).table_create('tbl_' + i.coerce_to('string')))) */

		suite.T().Log("About to run line #8: r.DBList().SetDifference([]interface{}{'rethinkdb', 'test'}).ForEach(func(db_name r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).ForEach(func(i r.Term) interface{} { return r.DB(db_name).TableCreate(r.Add('tbl_', i.CoerceTo('string')))})})")

		runAndAssert(suite.Suite, expected_, r.DBList().SetDifference([]interface{}{"rethinkdb", "test"}).ForEach(func(db_name r.Term) interface{} {
			return r.Expr([]interface{}{1, 2, 3}).ForEach(func(i r.Term) interface{} { return r.DB(db_name).TableCreate(r.Add("tbl_", i.CoerceTo("string"))) })
		}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #8")
	}

	{
		// meta/composite.py.yaml line #13
		/* partial({'dbs_dropped':3,'tables_dropped':9}) */
		var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 3, "tables_dropped": 9})
		/* r.db_list().set_difference(["rethinkdb", "test"]).for_each(r.db_drop(r.row)) */

		suite.T().Log("About to run line #13: r.DBList().SetDifference([]interface{}{'rethinkdb', 'test'}).ForEach(r.DBDrop(r.Row))")

		runAndAssert(suite.Suite, expected_, r.DBList().SetDifference([]interface{}{"rethinkdb", "test"}).ForEach(r.DBDrop(r.Row)), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #13")
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:52,代码来源:reql_meta_composite_test.go

示例2: TestCases

func (suite *DatumTypeofSuite) TestCases() {
	suite.T().Log("Running DatumTypeofSuite: These tests test the type of command")

	{
		// datum/typeof.yaml line #5
		/* 'NULL' */
		var expected_ string = "NULL"
		/* r.expr(null).type_of() */

		suite.T().Log("About to run line #5: r.Expr(nil).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Expr(nil).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #5")
	}

	{
		// datum/typeof.yaml line #9
		/* 'NULL' */
		var expected_ string = "NULL"
		/* r.type_of(null) */

		suite.T().Log("About to run line #9: r.TypeOf(nil)")

		runAndAssert(suite.Suite, expected_, r.TypeOf(nil), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #9")
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:33,代码来源:reql_datum_typeof_test.go

示例3: TestCases

func (suite *MathLogicMathSuite) TestCases() {
	suite.T().Log("Running MathLogicMathSuite: Tests of nested arithmetic expressions")

	{
		// math_logic/math.yaml line #4
		/* 1 */
		var expected_ int = 1
		/* (((4 + 2 * (r.expr(26) % 18)) / 5) - 3) */

		suite.T().Log("About to run line #4: r.Add(4, r.Mul(2, r.Expr(26).Mod(18))).Div(5).Sub(3)")

		runAndAssert(suite.Suite, expected_, r.Add(4, r.Mul(2, r.Expr(26).Mod(18))).Div(5).Sub(3), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #4")
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:18,代码来源:reql_math_logic_math_test.go

示例4: Example

func Example() {
	session, err := r.Connect(r.ConnectOpts{
		Address: url,
	})
	if err != nil {
		log.Fatalln(err)
	}

	res, err := r.Expr("Hello World").Run(session)
	if err != nil {
		log.Fatalln(err)
	}

	var response string
	err = res.One(&response)
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(response)

	// Output:
	// Hello World
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:24,代码来源:example_test.go

示例5: TestCases

func (suite *TimesIndexSuite) TestCases() {
	suite.T().Log("Running TimesIndexSuite: secondary indexes on times")

	tbl := r.DB("test").Table("tbl")
	_ = tbl // Prevent any noused variable errors

	// times/index.yaml line #7
	// ts={"timezone":"-07:00","epoch_time":1375445162.0872,"$reql_type$":"TIME"}
	suite.T().Log("Possibly executing: var ts map[interface{}]interface{} = map[interface{}]interface{}{'timezone': '-07:00', 'epoch_time': 1375445162.0872, '$reql_type$': 'TIME', }")

	ts := map[interface{}]interface{}{"timezone": "-07:00", "epoch_time": 1375445162.0872, "$reql_type$": "TIME"}
	_ = ts // Prevent any noused variable errors

	// times/index.yaml line #11
	// t1={"timezone":"-07:00","epoch_time":1375445163.0872,"$reql_type$":"TIME"}
	suite.T().Log("Possibly executing: var t1 map[interface{}]interface{} = map[interface{}]interface{}{'timezone': '-07:00', 'epoch_time': 1375445163.0872, '$reql_type$': 'TIME', }")

	t1 := map[interface{}]interface{}{"timezone": "-07:00", "epoch_time": 1375445163.0872, "$reql_type$": "TIME"}
	_ = t1 // Prevent any noused variable errors

	// times/index.yaml line #15
	// t2={"timezone":"-07:00","epoch_time":1375445163.08832,"$reql_type$":"TIME"}
	suite.T().Log("Possibly executing: var t2 map[interface{}]interface{} = map[interface{}]interface{}{'timezone': '-07:00', 'epoch_time': 1375445163.08832, '$reql_type$': 'TIME', }")

	t2 := map[interface{}]interface{}{"timezone": "-07:00", "epoch_time": 1375445163.08832, "$reql_type$": "TIME"}
	_ = t2 // Prevent any noused variable errors

	// times/index.yaml line #19
	// t3={"timezone":"-07:00","epoch_time":1375445163.08943,"$reql_type$":"TIME"}
	suite.T().Log("Possibly executing: var t3 map[interface{}]interface{} = map[interface{}]interface{}{'timezone': '-07:00', 'epoch_time': 1375445163.08943, '$reql_type$': 'TIME', }")

	t3 := map[interface{}]interface{}{"timezone": "-07:00", "epoch_time": 1375445163.08943, "$reql_type$": "TIME"}
	_ = t3 // Prevent any noused variable errors

	// times/index.yaml line #23
	// t4={"timezone":"-07:00","epoch_time":1375445163.09055,"$reql_type$":"TIME"}
	suite.T().Log("Possibly executing: var t4 map[interface{}]interface{} = map[interface{}]interface{}{'timezone': '-07:00', 'epoch_time': 1375445163.09055, '$reql_type$': 'TIME', }")

	t4 := map[interface{}]interface{}{"timezone": "-07:00", "epoch_time": 1375445163.09055, "$reql_type$": "TIME"}
	_ = t4 // Prevent any noused variable errors

	// times/index.yaml line #27
	// t5={"timezone":"-07:00","epoch_time":1375445163.09166,"$reql_type$":"TIME"}
	suite.T().Log("Possibly executing: var t5 map[interface{}]interface{} = map[interface{}]interface{}{'timezone': '-07:00', 'epoch_time': 1375445163.09166, '$reql_type$': 'TIME', }")

	t5 := map[interface{}]interface{}{"timezone": "-07:00", "epoch_time": 1375445163.09166, "$reql_type$": "TIME"}
	_ = t5 // Prevent any noused variable errors

	// times/index.yaml line #31
	// te={"timezone":"-07:00","epoch_time":1375445164.0872,"$reql_type$":"TIME"}
	suite.T().Log("Possibly executing: var te map[interface{}]interface{} = map[interface{}]interface{}{'timezone': '-07:00', 'epoch_time': 1375445164.0872, '$reql_type$': 'TIME', }")

	te := map[interface{}]interface{}{"timezone": "-07:00", "epoch_time": 1375445164.0872, "$reql_type$": "TIME"}
	_ = te // Prevent any noused variable errors

	// times/index.yaml line #36
	// trows = [{'id':t1}, {'id':t2}, {'id':t3}, {'id':t4}, {'id':t5}]
	suite.T().Log("Possibly executing: var trows []interface{} = []interface{}{map[interface{}]interface{}{'id': t1, }, map[interface{}]interface{}{'id': t2, }, map[interface{}]interface{}{'id': t3, }, map[interface{}]interface{}{'id': t4, }, map[interface{}]interface{}{'id': t5, }}")

	trows := []interface{}{map[interface{}]interface{}{"id": t1}, map[interface{}]interface{}{"id": t2}, map[interface{}]interface{}{"id": t3}, map[interface{}]interface{}{"id": t4}, map[interface{}]interface{}{"id": t5}}
	_ = trows // Prevent any noused variable errors

	{
		// times/index.yaml line #37
		/* 5 */
		var expected_ int = 5
		/* tbl.insert(trows)['inserted'] */

		suite.T().Log("About to run line #37: tbl.Insert(trows).AtIndex('inserted')")

		runAndAssert(suite.Suite, expected_, tbl.Insert(trows).AtIndex("inserted"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #37")
	}

	// times/index.yaml line #41
	// bad_insert = [{'id':r.expr(t1).in_timezone("Z")}]
	suite.T().Log("Possibly executing: var bad_insert []interface{} = []interface{}{map[interface{}]interface{}{'id': r.Expr(t1).InTimezone('Z'), }}")

	bad_insert := []interface{}{map[interface{}]interface{}{"id": r.Expr(t1).InTimezone("Z")}}
	_ = bad_insert // Prevent any noused variable errors

	{
		// times/index.yaml line #42
		/* ("Duplicate primary key `id`:\n{\n\t\"id\":\t{\n\t\t\"$reql_type$\":\t\"TIME\",\n\t\t\"epoch_time\":\t1375445163.087,\n\t\t\"timezone\":\t\"-07:00\"\n\t}\n}\n{\n\t\"id\":\t{\n\t\t\"$reql_type$\":\t\"TIME\",\n\t\t\"epoch_time\":\t1375445163.087,\n\t\t\"timezone\":\t\"+00:00\"\n\t}\n}") */
		var expected_ string = "Duplicate primary key `id`:\n{\n\t\"id\":\t{\n\t\t\"$reql_type$\":\t\"TIME\",\n\t\t\"epoch_time\":\t1375445163.087,\n\t\t\"timezone\":\t\"-07:00\"\n\t}\n}\n{\n\t\"id\":\t{\n\t\t\"$reql_type$\":\t\"TIME\",\n\t\t\"epoch_time\":\t1375445163.087,\n\t\t\"timezone\":\t\"+00:00\"\n\t}\n}"
		/* tbl.insert(bad_insert)['first_error'] */

		suite.T().Log("About to run line #42: tbl.Insert(bad_insert).AtIndex('first_error')")

		runAndAssert(suite.Suite, expected_, tbl.Insert(bad_insert).AtIndex("first_error"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #42")
	}

	{
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_times_index_test.go

示例6: TestCases

func (suite *TimesTimeArithSuite) TestCases() {
	suite.T().Log("Running TimesTimeArithSuite: Test basic time arithmetic")

	// times/time_arith.yaml line #3
	// rt1 = 1375147296.681
	suite.T().Log("Possibly executing: var rt1 float64 = 1375147296.681")

	rt1 := 1375147296.681
	_ = rt1 // Prevent any noused variable errors

	// times/time_arith.yaml line #4
	// rt2 = 1375147296.682
	suite.T().Log("Possibly executing: var rt2 float64 = 1375147296.682")

	rt2 := 1375147296.682
	_ = rt2 // Prevent any noused variable errors

	// times/time_arith.yaml line #5
	// rt3 = 1375147297.681
	suite.T().Log("Possibly executing: var rt3 float64 = 1375147297.681")

	rt3 := 1375147297.681
	_ = rt3 // Prevent any noused variable errors

	// times/time_arith.yaml line #6
	// rt4 = 2375147296.681
	suite.T().Log("Possibly executing: var rt4 float64 = 2375147296.681")

	rt4 := 2375147296.681
	_ = rt4 // Prevent any noused variable errors

	// times/time_arith.yaml line #7
	// rts = [rt1, rt2, rt3, rt4]
	suite.T().Log("Possibly executing: var rts []interface{} = []interface{}{rt1, rt2, rt3, rt4}")

	rts := []interface{}{rt1, rt2, rt3, rt4}
	_ = rts // Prevent any noused variable errors

	// times/time_arith.yaml line #9
	// t1 = r.epoch_time(rt1)
	suite.T().Log("Possibly executing: var t1 r.Term = r.EpochTime(rt1)")

	t1 := r.EpochTime(rt1)
	_ = t1 // Prevent any noused variable errors

	// times/time_arith.yaml line #10
	// t2 = r.epoch_time(rt2)
	suite.T().Log("Possibly executing: var t2 r.Term = r.EpochTime(rt2)")

	t2 := r.EpochTime(rt2)
	_ = t2 // Prevent any noused variable errors

	// times/time_arith.yaml line #11
	// t3 = r.epoch_time(rt3)
	suite.T().Log("Possibly executing: var t3 r.Term = r.EpochTime(rt3)")

	t3 := r.EpochTime(rt3)
	_ = t3 // Prevent any noused variable errors

	// times/time_arith.yaml line #12
	// t4 = r.epoch_time(rt4)
	suite.T().Log("Possibly executing: var t4 r.Term = r.EpochTime(rt4)")

	t4 := r.EpochTime(rt4)
	_ = t4 // Prevent any noused variable errors

	// times/time_arith.yaml line #13
	// ts = r.expr([t1, t2, t3, t4])
	suite.T().Log("Possibly executing: var ts r.Term = r.Expr([]interface{}{t1, t2, t3, t4})")

	ts := r.Expr([]interface{}{t1, t2, t3, t4})
	_ = ts // Prevent any noused variable errors

	{
		// times/time_arith.yaml line #17
		/* true */
		var expected_ bool = true
		/* ((t2 - t1) * 1000).do(lambda x:(x > 0.99) & (x < 1.01)) */

		suite.T().Log("About to run line #17: r.Sub(t2, t1).Mul(1000).Do(func(x r.Term) interface{} { return r.Gt(x, 0.99).And(r.Lt(x, 1.01))})")

		runAndAssert(suite.Suite, expected_, r.Sub(t2, t1).Mul(1000).Do(func(x r.Term) interface{} { return r.Gt(x, 0.99).And(r.Lt(x, 1.01)) }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #17")
	}

	{
		// times/time_arith.yaml line #20
		/* 1 */
		var expected_ int = 1
		/* t3 - t1 */

		suite.T().Log("About to run line #20: r.Sub(t3, t1)")

		runAndAssert(suite.Suite, expected_, r.Sub(t3, t1), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_times_time_arith_test.go

示例7: TestCases


//.........这里部分代码省略.........
		var expected_ bool = false
		/* r.line([1,1], [2,1]).intersects(r.point(1.5,1.5)) */

		suite.T().Log("About to run line #59: r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Point(1.5, 1.5))")

		runAndAssert(suite.Suite, expected_, r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Point(1.5, 1.5)), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #59")
	}

	{
		// geo/intersection_inclusion.yaml line #61
		/* true */
		var expected_ bool = true
		/* r.line([1,1], [2,1]).intersects(r.line([2,1], [3,1])) */

		suite.T().Log("About to run line #61: r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Line([]interface{}{2, 1}, []interface{}{3, 1}))")

		runAndAssert(suite.Suite, expected_, r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Line([]interface{}{2, 1}, []interface{}{3, 1})), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #61")
	}

	{
		// geo/intersection_inclusion.yaml line #64
		/* 2 */
		var expected_ int = 2
		/* r.expr([r.point(1, 0), r.point(3,0), r.point(2, 0)]).intersects(r.line([0,0], [2, 0])).count() */

		suite.T().Log("About to run line #64: r.Expr([]interface{}{r.Point(1, 0), r.Point(3, 0), r.Point(2, 0)}).Intersects(r.Line([]interface{}{0, 0}, []interface{}{2, 0})).Count()")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Point(1, 0), r.Point(3, 0), r.Point(2, 0)}).Intersects(r.Line([]interface{}{0, 0}, []interface{}{2, 0})).Count(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #64")
	}

	{
		// geo/intersection_inclusion.yaml line #68
		/* true */
		var expected_ bool = true
		/* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(1.5,1.5)) */

		suite.T().Log("About to run line #68: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(1.5, 1.5))")

		runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(1.5, 1.5)), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #68")
	}

	{
		// geo/intersection_inclusion.yaml line #70
		/* false */
		var expected_ bool = false
		/* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(2.5,2.5)) */

		suite.T().Log("About to run line #70: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2.5, 2.5))")

		runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2.5, 2.5)), suite.session, r.RunOpts{
开发者ID:freedmand,项目名称:doc.vu,代码行数:67,代码来源:reql_geo_intersection_inclusion_test.go

示例8: TestCases

func (suite *DatumBoolSuite) TestCases() {
	suite.T().Log("Running DatumBoolSuite: Tests of conversion to and from the RQL bool type")

	{
		// datum/bool.yaml line #3
		/* true */
		var expected_ bool = true
		/* r.expr(True) */

		suite.T().Log("About to run line #3: r.Expr(true)")

		runAndAssert(suite.Suite, expected_, r.Expr(true), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #3")
	}

	{
		// datum/bool.yaml line #10
		/* false */
		var expected_ bool = false
		/* r.expr(False) */

		suite.T().Log("About to run line #10: r.Expr(false)")

		runAndAssert(suite.Suite, expected_, r.Expr(false), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #10")
	}

	{
		// datum/bool.yaml line #17
		/* 'BOOL' */
		var expected_ string = "BOOL"
		/* r.expr(False).type_of() */

		suite.T().Log("About to run line #17: r.Expr(false).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Expr(false).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #17")
	}

	{
		// datum/bool.yaml line #21
		/* 'true' */
		var expected_ string = "true"
		/* r.expr(True).coerce_to('string') */

		suite.T().Log("About to run line #21: r.Expr(true).CoerceTo('string')")

		runAndAssert(suite.Suite, expected_, r.Expr(true).CoerceTo("string"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #21")
	}

	{
		// datum/bool.yaml line #24
		/* True */
		var expected_ bool = true
		/* r.expr(True).coerce_to('bool') */

		suite.T().Log("About to run line #24: r.Expr(true).CoerceTo('bool')")

		runAndAssert(suite.Suite, expected_, r.Expr(true).CoerceTo("bool"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #24")
	}

	{
		// datum/bool.yaml line #27
		/* False */
		var expected_ bool = false
		/* r.expr(False).coerce_to('bool') */

		suite.T().Log("About to run line #27: r.Expr(false).CoerceTo('bool')")

		runAndAssert(suite.Suite, expected_, r.Expr(false).CoerceTo("bool"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #27")
	}

	{
		// datum/bool.yaml line #30
		/* False */
		var expected_ bool = false
		/* r.expr(null).coerce_to('bool') */

		suite.T().Log("About to run line #30: r.Expr(nil).CoerceTo('bool')")
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_datum_bool_test.go

示例9: TestCases

func (suite *TransformArraySuite) TestCases() {
	suite.T().Log("Running TransformArraySuite: Tests manipulation operations on arrays")

	// transform/array.yaml line #5
	// arr = r.expr([1, 2, 3])
	suite.T().Log("Possibly executing: var arr r.Term = r.Expr([]interface{}{1, 2, 3})")

	arr := r.Expr([]interface{}{1, 2, 3})
	_ = arr // Prevent any noused variable errors

	// transform/array.yaml line #6
	// dupe_arr = r.expr([1, 1, 2, 3])
	suite.T().Log("Possibly executing: var dupe_arr r.Term = r.Expr([]interface{}{1, 1, 2, 3})")

	dupe_arr := r.Expr([]interface{}{1, 1, 2, 3})
	_ = dupe_arr // Prevent any noused variable errors

	// transform/array.yaml line #7
	// objArr = r.expr([{'a':1, 'b':'a'}, {'a':2, 'b':'b'}, {'a':3, 'b':'c'}])
	suite.T().Log("Possibly executing: var objArr r.Term = r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, 'b': 'a', }, map[interface{}]interface{}{'a': 2, 'b': 'b', }, map[interface{}]interface{}{'a': 3, 'b': 'c', }})")

	objArr := r.Expr([]interface{}{map[interface{}]interface{}{"a": 1, "b": "a"}, map[interface{}]interface{}{"a": 2, "b": "b"}, map[interface{}]interface{}{"a": 3, "b": "c"}})
	_ = objArr // Prevent any noused variable errors

	// transform/array.yaml line #8
	// nestedObjArr = r.expr([{'a':1, 'b':{'c':1}}, {'a':2, 'b':{'c':2}}, {'a':3, 'b':{'c':3}}])
	suite.T().Log("Possibly executing: var nestedObjArr r.Term = r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, 'b': map[interface{}]interface{}{'c': 1, }, }, map[interface{}]interface{}{'a': 2, 'b': map[interface{}]interface{}{'c': 2, }, }, map[interface{}]interface{}{'a': 3, 'b': map[interface{}]interface{}{'c': 3, }, }})")

	nestedObjArr := r.Expr([]interface{}{map[interface{}]interface{}{"a": 1, "b": map[interface{}]interface{}{"c": 1}}, map[interface{}]interface{}{"a": 2, "b": map[interface{}]interface{}{"c": 2}}, map[interface{}]interface{}{"a": 3, "b": map[interface{}]interface{}{"c": 3}}})
	_ = nestedObjArr // Prevent any noused variable errors

	{
		// transform/array.yaml line #12
		/* [1,2,3,4] */
		var expected_ []interface{} = []interface{}{1, 2, 3, 4}
		/* arr.append(4) */

		suite.T().Log("About to run line #12: arr.Append(4)")

		runAndAssert(suite.Suite, expected_, arr.Append(4), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #12")
	}

	{
		// transform/array.yaml line #14
		/* [1,2,3,'a'] */
		var expected_ []interface{} = []interface{}{1, 2, 3, "a"}
		/* arr.append('a') */

		suite.T().Log("About to run line #14: arr.Append('a')")

		runAndAssert(suite.Suite, expected_, arr.Append("a"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #14")
	}

	{
		// transform/array.yaml line #19
		/* [0,1,2,3] */
		var expected_ []interface{} = []interface{}{0, 1, 2, 3}
		/* arr.prepend(0) */

		suite.T().Log("About to run line #19: arr.Prepend(0)")

		runAndAssert(suite.Suite, expected_, arr.Prepend(0), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #19")
	}

	{
		// transform/array.yaml line #21
		/* ['a',1,2,3] */
		var expected_ []interface{} = []interface{}{"a", 1, 2, 3}
		/* arr.prepend('a') */

		suite.T().Log("About to run line #21: arr.Prepend('a')")

		runAndAssert(suite.Suite, expected_, arr.Prepend("a"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #21")
	}

	{
		// transform/array.yaml line #26
		/* [3] */
		var expected_ []interface{} = []interface{}{3}
		/* arr.difference([1,2,2]) */

		suite.T().Log("About to run line #26: arr.Difference([]interface{}{1, 2, 2})")

		runAndAssert(suite.Suite, expected_, arr.Difference([]interface{}{1, 2, 2}), suite.session, r.RunOpts{
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_transform_array_test.go

示例10: TestCases

func (suite *DatumObjectSuite) TestCases() {
	suite.T().Log("Running DatumObjectSuite: Tests conversion to and from the RQL object type")

	{
		// datum/object.yaml line #6
		/* {} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{}
		/* r.expr({}) */

		suite.T().Log("About to run line #6: r.Expr(map[interface{}]interface{}{})")

		runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #6")
	}

	{
		// datum/object.yaml line #11
		/* {'a':1} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1}
		/* r.expr({'a':1}) */

		suite.T().Log("About to run line #11: r.Expr(map[interface{}]interface{}{'a': 1, })")

		runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #11")
	}

	{
		// datum/object.yaml line #16
		/* {'a':1, 'b':'two', 'c':True} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1, "b": "two", "c": true}
		/* r.expr({'a':1, 'b':'two', 'c':True}) */

		suite.T().Log("About to run line #16: r.Expr(map[interface{}]interface{}{'a': 1, 'b': 'two', 'c': true, })")

		runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1, "b": "two", "c": true}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #16")
	}

	{
		// datum/object.yaml line #20
		/* {'a':1} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1}
		/* r.expr({'a':r.expr(1)}) */

		suite.T().Log("About to run line #20: r.Expr(map[interface{}]interface{}{'a': r.Expr(1), })")

		runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": r.Expr(1)}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #20")
	}

	{
		// datum/object.yaml line #23
		/* {'a':{'b':[{'c':2}, 'a', 4]}} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": map[interface{}]interface{}{"b": []interface{}{map[interface{}]interface{}{"c": 2}, "a", 4}}}
		/* r.expr({'a':{'b':[{'c':2}, 'a', 4]}}) */

		suite.T().Log("About to run line #23: r.Expr(map[interface{}]interface{}{'a': map[interface{}]interface{}{'b': []interface{}{map[interface{}]interface{}{'c': 2, }, 'a', 4}, }, })")

		runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": map[interface{}]interface{}{"b": []interface{}{map[interface{}]interface{}{"c": 2}, "a", 4}}}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #23")
	}

	{
		// datum/object.yaml line #26
		/* 'OBJECT' */
		var expected_ string = "OBJECT"
		/* r.expr({'a':1}).type_of() */

		suite.T().Log("About to run line #26: r.Expr(map[interface{}]interface{}{'a': 1, }).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #26")
	}

	{
		// datum/object.yaml line #30
		/* '{"a":1}' */
		var expected_ string = "{\"a\":1}"
		/* r.expr({'a':1}).coerce_to('string') */

		suite.T().Log("About to run line #30: r.Expr(map[interface{}]interface{}{'a': 1, }).CoerceTo('string')")
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_datum_object_test.go

示例11: TestCases

func (suite *TimesTimezonesSuite) TestCases() {
	suite.T().Log("Running TimesTimezonesSuite: Test basic timezone manipulation")

	// times/timezones.yaml line #3
	// t1 = r.time(2013, r.july, 29, 23, 30, 0, "+00:00")
	suite.T().Log("Possibly executing: var t1 r.Term = r.Time(2013, r.July, 29, 23, 30, 0, '+00:00')")

	t1 := r.Time(2013, r.July, 29, 23, 30, 0, "+00:00")
	_ = t1 // Prevent any noused variable errors

	// times/timezones.yaml line #5
	// tutc1 = t1.in_timezone("Z")
	suite.T().Log("Possibly executing: var tutc1 r.Term = t1.InTimezone('Z')")

	tutc1 := t1.InTimezone("Z")
	_ = tutc1 // Prevent any noused variable errors

	// times/timezones.yaml line #6
	// tutc2 = t1.in_timezone("+00:00")
	suite.T().Log("Possibly executing: var tutc2 r.Term = t1.InTimezone('+00:00')")

	tutc2 := t1.InTimezone("+00:00")
	_ = tutc2 // Prevent any noused variable errors

	// times/timezones.yaml line #7
	// tutc3 = t1.in_timezone("+00")
	suite.T().Log("Possibly executing: var tutc3 r.Term = t1.InTimezone('+00')")

	tutc3 := t1.InTimezone("+00")
	_ = tutc3 // Prevent any noused variable errors

	// times/timezones.yaml line #8
	// tutcs = r.expr([tutc1, tutc2, tutc3])
	suite.T().Log("Possibly executing: var tutcs r.Term = r.Expr([]interface{}{tutc1, tutc2, tutc3})")

	tutcs := r.Expr([]interface{}{tutc1, tutc2, tutc3})
	_ = tutcs // Prevent any noused variable errors

	// times/timezones.yaml line #10
	// tm1 = t1.in_timezone("-00:59")
	suite.T().Log("Possibly executing: var tm1 r.Term = t1.InTimezone('-00:59')")

	tm1 := t1.InTimezone("-00:59")
	_ = tm1 // Prevent any noused variable errors

	// times/timezones.yaml line #11
	// tm2 = t1.in_timezone("-01:00")
	suite.T().Log("Possibly executing: var tm2 r.Term = t1.InTimezone('-01:00')")

	tm2 := t1.InTimezone("-01:00")
	_ = tm2 // Prevent any noused variable errors

	// times/timezones.yaml line #12
	// tm3 = t1.in_timezone("-01:01")
	suite.T().Log("Possibly executing: var tm3 r.Term = t1.InTimezone('-01:01')")

	tm3 := t1.InTimezone("-01:01")
	_ = tm3 // Prevent any noused variable errors

	// times/timezones.yaml line #13
	// tms = r.expr([tm1, tm2, tm3])
	suite.T().Log("Possibly executing: var tms r.Term = r.Expr([]interface{}{tm1, tm2, tm3})")

	tms := r.Expr([]interface{}{tm1, tm2, tm3})
	_ = tms // Prevent any noused variable errors

	// times/timezones.yaml line #15
	// tp1 = t1.in_timezone("+00:59")
	suite.T().Log("Possibly executing: var tp1 r.Term = t1.InTimezone('+00:59')")

	tp1 := t1.InTimezone("+00:59")
	_ = tp1 // Prevent any noused variable errors

	// times/timezones.yaml line #16
	// tp2 = t1.in_timezone("+01:00")
	suite.T().Log("Possibly executing: var tp2 r.Term = t1.InTimezone('+01:00')")

	tp2 := t1.InTimezone("+01:00")
	_ = tp2 // Prevent any noused variable errors

	// times/timezones.yaml line #17
	// tp3 = t1.in_timezone("+01:01")
	suite.T().Log("Possibly executing: var tp3 r.Term = t1.InTimezone('+01:01')")

	tp3 := t1.InTimezone("+01:01")
	_ = tp3 // Prevent any noused variable errors

	// times/timezones.yaml line #18
	// tps = r.expr([tp1, tp2, tp3])
	suite.T().Log("Possibly executing: var tps r.Term = r.Expr([]interface{}{tp1, tp2, tp3})")

	tps := r.Expr([]interface{}{tp1, tp2, tp3})
	_ = tps // Prevent any noused variable errors

	// times/timezones.yaml line #20
	// ts = tutcs.union(tms).union(tps).union([t1])
	suite.T().Log("Possibly executing: var ts r.Term = tutcs.Union(tms).Union(tps).Union([]interface{}{t1})")

	ts := tutcs.Union(tms).Union(tps).Union([]interface{}{t1})
	_ = ts // Prevent any noused variable errors
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_times_timezones_test.go

示例12: TestCases

func (suite *DatumNullSuite) TestCases() {
	suite.T().Log("Running DatumNullSuite: Tests of conversion to and from the RQL null type")

	{
		// datum/null.yaml line #6
		/* (null) */
		var expected_ interface{} = nil
		/* r.expr(null) */

		suite.T().Log("About to run line #6: r.Expr(nil)")

		runAndAssert(suite.Suite, expected_, r.Expr(nil), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #6")
	}

	{
		// datum/null.yaml line #9
		/* 'NULL' */
		var expected_ string = "NULL"
		/* r.expr(null).type_of() */

		suite.T().Log("About to run line #9: r.Expr(nil).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Expr(nil).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #9")
	}

	{
		// datum/null.yaml line #14
		/* 'null' */
		var expected_ string = "null"
		/* r.expr(null).coerce_to('string') */

		suite.T().Log("About to run line #14: r.Expr(nil).CoerceTo('string')")

		runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("string"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #14")
	}

	{
		// datum/null.yaml line #17
		/* null */
		var expected_ interface{} = nil
		/* r.expr(null).coerce_to('null') */

		suite.T().Log("About to run line #17: r.Expr(nil).CoerceTo('null')")

		runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("null"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #17")
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:63,代码来源:reql_datum_null_test.go

示例13: TestCases

func (suite *DatumUuidSuite) TestCases() {
	suite.T().Log("Running DatumUuidSuite: Test that UUIDs work")

	{
		// datum/uuid.yaml line #3
		/* uuid() */
		var expected_ compare.Regex = compare.IsUUID()
		/* r.uuid() */

		suite.T().Log("About to run line #3: r.UUID()")

		runAndAssert(suite.Suite, expected_, r.UUID(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #3")
	}

	{
		// datum/uuid.yaml line #5
		/* uuid() */
		var expected_ compare.Regex = compare.IsUUID()
		/* r.expr(r.uuid()) */

		suite.T().Log("About to run line #5: r.Expr(r.UUID())")

		runAndAssert(suite.Suite, expected_, r.Expr(r.UUID()), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #5")
	}

	{
		// datum/uuid.yaml line #7
		/* 'STRING' */
		var expected_ string = "STRING"
		/* r.type_of(r.uuid()) */

		suite.T().Log("About to run line #7: r.TypeOf(r.UUID())")

		runAndAssert(suite.Suite, expected_, r.TypeOf(r.UUID()), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #7")
	}

	{
		// datum/uuid.yaml line #9
		/* true */
		var expected_ bool = true
		/* r.uuid().ne(r.uuid()) */

		suite.T().Log("About to run line #9: r.UUID().Ne(r.UUID())")

		runAndAssert(suite.Suite, expected_, r.UUID().Ne(r.UUID()), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #9")
	}

	{
		// datum/uuid.yaml line #11
		/* ('97dd10a5-4fc4-554f-86c5-0d2c2e3d5330') */
		var expected_ string = "97dd10a5-4fc4-554f-86c5-0d2c2e3d5330"
		/* r.uuid('magic') */

		suite.T().Log("About to run line #11: r.UUID('magic')")

		runAndAssert(suite.Suite, expected_, r.UUID("magic"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #11")
	}

	{
		// datum/uuid.yaml line #13
		/* true */
		var expected_ bool = true
		/* r.uuid('magic').eq(r.uuid('magic')) */

		suite.T().Log("About to run line #13: r.UUID('magic').Eq(r.UUID('magic'))")

		runAndAssert(suite.Suite, expected_, r.UUID("magic").Eq(r.UUID("magic")), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #13")
	}

	{
		// datum/uuid.yaml line #15
		/* true */
		var expected_ bool = true
		/* r.uuid('magic').ne(r.uuid('beans')) */

		suite.T().Log("About to run line #15: r.UUID('magic').Ne(r.UUID('beans'))")
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_datum_uuid_test.go

示例14: TestCases

func (suite *TransformMapSuite) TestCases() {
	suite.T().Log("Running TransformMapSuite: Tests the RQL `map` function")

	{
		// transform/map.yaml line #5
		/* 'STREAM' */
		var expected_ string = "STREAM"
		/* r.range().map(r.range(), lambda x, y:(x, y)).type_of() */

		suite.T().Log("About to run line #5: r.Range().Map(r.Range(), func(x r.Term, y r.Term) interface{} { return []interface{}{x, y}}).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Range().Map(r.Range(), func(x r.Term, y r.Term) interface{} { return []interface{}{x, y} }).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #5")
	}

	{
		// transform/map.yaml line #10
		/* 'STREAM' */
		var expected_ string = "STREAM"
		/* r.range().map(r.expr([]), lambda x, y:(x, y)).type_of() */

		suite.T().Log("About to run line #10: r.Range().Map(r.Expr([]interface{}{}), func(x r.Term, y r.Term) interface{} { return []interface{}{x, y}}).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Range().Map(r.Expr([]interface{}{}), func(x r.Term, y r.Term) interface{} { return []interface{}{x, y} }).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #10")
	}

	{
		// transform/map.yaml line #15
		/* 'ARRAY' */
		var expected_ string = "ARRAY"
		/* r.expr([]).map(r.expr([]), lambda x, y:(x, y)).type_of() */

		suite.T().Log("About to run line #15: r.Expr([]interface{}{}).Map(r.Expr([]interface{}{}), func(x r.Term, y r.Term) interface{} { return []interface{}{x, y}}).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Map(r.Expr([]interface{}{}), func(x r.Term, y r.Term) interface{} { return []interface{}{x, y} }).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #15")
	}

	{
		// transform/map.yaml line #21
		/* [0, 0, 0] */
		var expected_ []interface{} = []interface{}{0, 0, 0}
		/* r.range(3).map(lambda:0) */

		suite.T().Log("About to run line #21: r.Range(3).Map(func() interface{} { return 0})")

		runAndAssert(suite.Suite, expected_, r.Range(3).Map(func() interface{} { return 0 }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #21")
	}

	{
		// transform/map.yaml line #26
		/* [0, 0, 0] */
		var expected_ []interface{} = []interface{}{0, 0, 0}
		/* r.range(3).map(r.range(4), lambda x,y:0) */

		suite.T().Log("About to run line #26: r.Range(3).Map(r.Range(4), func(x r.Term, y r.Term) interface{} { return 0})")

		runAndAssert(suite.Suite, expected_, r.Range(3).Map(r.Range(4), func(x r.Term, y r.Term) interface{} { return 0 }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #26")
	}

	{
		// transform/map.yaml line #31
		/* [[1]] */
		var expected_ []interface{} = []interface{}{[]interface{}{1}}
		/* r.expr([1]).map(lambda x:(x,)) */

		suite.T().Log("About to run line #31: r.Expr([]interface{}{1}).Map(func(x r.Term) interface{} { return []interface{}{x}})")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1}).Map(func(x r.Term) interface{} { return []interface{}{x} }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #31")
	}

	{
		// transform/map.yaml line #36
		/* [[1, 1]] */
		var expected_ []interface{} = []interface{}{[]interface{}{1, 1}}
		/* r.expr([1]).map(r.expr([1]), lambda x, y:(x, y)) */

		suite.T().Log("About to run line #36: r.Expr([]interface{}{1}).Map(r.Expr([]interface{}{1}), func(x r.Term, y r.Term) interface{} { return []interface{}{x, y}})")
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_transform_map_test.go

示例15: TestCases

func (suite *RandomSuite) TestCases() {
	suite.T().Log("Running RandomSuite: Tests randomization functions")

	{
		// random.yaml line #5
		/* 3 */
		var expected_ int = 3
		/* r.expr([1,2,3]).sample(3).distinct().count() */

		suite.T().Log("About to run line #5: r.Expr([]interface{}{1, 2, 3}).Sample(3).Distinct().Count()")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(3).Distinct().Count(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #5")
	}

	{
		// random.yaml line #7
		/* 3 */
		var expected_ int = 3
		/* r.expr([1,2,3]).sample(3).count() */

		suite.T().Log("About to run line #7: r.Expr([]interface{}{1, 2, 3}).Sample(3).Count()")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(3).Count(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #7")
	}

	{
		// random.yaml line #9
		/* 3 */
		var expected_ int = 3
		/* r.expr([1,2,3,4,5,6]).sample(3).distinct().count() */

		suite.T().Log("About to run line #9: r.Expr([]interface{}{1, 2, 3, 4, 5, 6}).Sample(3).Distinct().Count()")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4, 5, 6}).Sample(3).Distinct().Count(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #9")
	}

	{
		// random.yaml line #11
		/* 3 */
		var expected_ int = 3
		/* r.expr([1,2,3]).sample(4).distinct().count() */

		suite.T().Log("About to run line #11: r.Expr([]interface{}{1, 2, 3}).Sample(4).Distinct().Count()")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(4).Distinct().Count(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #11")
	}

	{
		// random.yaml line #15
		/* err('ReqlQueryLogicError', 'Number of items to sample must be non-negative, got `-1`.', [0]) */
		var expected_ Err = err("ReqlQueryLogicError", "Number of items to sample must be non-negative, got `-1`.")
		/* r.expr([1,2,3]).sample(-1) */

		suite.T().Log("About to run line #15: r.Expr([]interface{}{1, 2, 3}).Sample(-1)")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(-1), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #15")
	}

	{
		// random.yaml line #17
		/* err('ReqlQueryLogicError', 'Cannot convert NUMBER to SEQUENCE', [0]) */
		var expected_ Err = err("ReqlQueryLogicError", "Cannot convert NUMBER to SEQUENCE")
		/* r.expr(1).sample(1) */

		suite.T().Log("About to run line #17: r.Expr(1).Sample(1)")

		runAndAssert(suite.Suite, expected_, r.Expr(1).Sample(1), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #17")
	}

	{
		// random.yaml line #19
		/* err('ReqlQueryLogicError', 'Cannot convert OBJECT to SEQUENCE', [0]) */
		var expected_ Err = err("ReqlQueryLogicError", "Cannot convert OBJECT to SEQUENCE")
		/* r.expr({}).sample(1) */

		suite.T().Log("About to run line #19: r.Expr(map[interface{}]interface{}{}).Sample(1)")
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_random_test.go


注:本文中的gopkg/in/dancannon/gorethink/v2.Expr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。