Exemplo n.º 1
0
func (suite *JsonSuite) TestCases() {
	suite.T().Log("Running JsonSuite: Tests RQL json parsing")

	{
		// json.yaml line #4
		/* [1,2,3] */
		var expected_ []interface{} = []interface{}{1, 2, 3}
		/* r.json("[1,2,3]") */

		suite.T().Log("About to run line #4: r.JSON('[1,2,3]')")

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

	{
		// json.yaml line #7
		/* 1 */
		var expected_ int = 1
		/* r.json("1") */

		suite.T().Log("About to run line #7: r.JSON('1')")

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

	{
		// json.yaml line #10
		/* {} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{}
		/* r.json("{}") */

		suite.T().Log("About to run line #10: r.JSON('{}')")

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

	{
		// json.yaml line #13
		/* "foo" */
		var expected_ string = "foo"
		/* r.json('"foo"') */

		suite.T().Log("About to run line #13: r.JSON('\\'foo\\'')")

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

	{
		// json.yaml line #16
		/* err("ReqlQueryLogicError", 'Failed to parse "[1,2" as JSON:' + ' Missing a comma or \']\' after an array element.', [0]) */
		var expected_ Err = err("ReqlQueryLogicError", "Failed to parse \"[1,2\" as JSON:"+" Missing a comma or ']' after an array element.")
		/* r.json("[1,2") */

		suite.T().Log("About to run line #16: r.JSON('[1,2')")

		runAndAssert(suite.Suite, expected_, r.JSON("[1,2"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #16")
	}

	{
		// json.yaml line #19
		/* '[1,2,3]' */
		var expected_ string = "[1,2,3]"
		/* r.json("[1,2,3]").to_json_string() */

		suite.T().Log("About to run line #19: r.JSON('[1,2,3]').ToJSON()")

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

	{
		// json.yaml line #23
		/* '[1,2,3]' */
		var expected_ string = "[1,2,3]"
		/* r.json("[1,2,3]").to_json() */

		suite.T().Log("About to run line #23: r.JSON('[1,2,3]').ToJSON()")

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

	{
		// json.yaml line #26
		/* '{"foo":4}' */
		var expected_ string = "{\"foo\":4}"
		/* r.json("{\"foo\":4}").to_json_string() */

		suite.T().Log("About to run line #26: r.JSON('{\\'foo\\':4}').ToJSON()")

		runAndAssert(suite.Suite, expected_, r.JSON("{\"foo\":4}").ToJSON(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #26")
	}

	{
		// json.yaml line #30
		/* '{"foo":4}' */
		var expected_ string = "{\"foo\":4}"
		/* r.json("{\"foo\":4}").to_json() */

		suite.T().Log("About to run line #30: r.JSON('{\\'foo\\':4}').ToJSON()")

		runAndAssert(suite.Suite, expected_, r.JSON("{\"foo\":4}").ToJSON(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #30")
	}

	// json.yaml line #34
	// text = '[{"id":1,"first_name":"Harry","last_name":"Riley","email":"*****@*****.**","country":"Andorra","ip_address":"221.25.65.136"},{"id":2,"first_name":"Bonnie","last_name":"Anderson","email":"*****@*****.**","country":"Tuvalu","ip_address":"116.162.43.150"},{"id":3,"first_name":"Marie","last_name":"Schmidt","email":"*****@*****.**","country":"Iraq","ip_address":"181.105.59.57"},{"id":4,"first_name":"Phillip","last_name":"Willis","email":"*****@*****.**","country":"Montenegro","ip_address":"24.223.139.156"}]'
	suite.T().Log("Possibly executing: var text string = '[{\\'id\\':1,\\'first_name\\':\\'Harry\\',\\'last_name\\':\\'Riley\\',\\'email\\':\\'[email protected]\\',\\'country\\':\\'Andorra\\',\\'ip_address\\':\\'221.25.65.136\\'},{\\'id\\':2,\\'first_name\\':\\'Bonnie\\',\\'last_name\\':\\'Anderson\\',\\'email\\':\\'[email protected]\\',\\'country\\':\\'Tuvalu\\',\\'ip_address\\':\\'116.162.43.150\\'},{\\'id\\':3,\\'first_name\\':\\'Marie\\',\\'last_name\\':\\'Schmidt\\',\\'email\\':\\'[email protected]\\',\\'country\\':\\'Iraq\\',\\'ip_address\\':\\'181.105.59.57\\'},{\\'id\\':4,\\'first_name\\':\\'Phillip\\',\\'last_name\\':\\'Willis\\',\\'email\\':\\'[email protected]\\',\\'country\\':\\'Montenegro\\',\\'ip_address\\':\\'24.223.139.156\\'}]'")

	text := "[{\"id\":1,\"first_name\":\"Harry\",\"last_name\":\"Riley\",\"email\":\"[email protected]\",\"country\":\"Andorra\",\"ip_address\":\"221.25.65.136\"},{\"id\":2,\"first_name\":\"Bonnie\",\"last_name\":\"Anderson\",\"email\":\"[email protected]\",\"country\":\"Tuvalu\",\"ip_address\":\"116.162.43.150\"},{\"id\":3,\"first_name\":\"Marie\",\"last_name\":\"Schmidt\",\"email\":\"[email protected]\",\"country\":\"Iraq\",\"ip_address\":\"181.105.59.57\"},{\"id\":4,\"first_name\":\"Phillip\",\"last_name\":\"Willis\",\"email\":\"[email protected]\",\"country\":\"Montenegro\",\"ip_address\":\"24.223.139.156\"}]"
	_ = text // Prevent any noused variable errors

	// json.yaml line #35
	// sorted = '[{"country":"Andorra","email":"*****@*****.**","first_name":"Harry","id":1,"ip_address":"221.25.65.136","last_name":"Riley"},{"country":"Tuvalu","email":"*****@*****.**","first_name":"Bonnie","id":2,"ip_address":"116.162.43.150","last_name":"Anderson"},{"country":"Iraq","email":"*****@*****.**","first_name":"Marie","id":3,"ip_address":"181.105.59.57","last_name":"Schmidt"},{"country":"Montenegro","email":"*****@*****.**","first_name":"Phillip","id":4,"ip_address":"24.223.139.156","last_name":"Willis"}]'
	suite.T().Log("Possibly executing: var sorted string = '[{\\'country\\':\\'Andorra\\',\\'email\\':\\'[email protected]\\',\\'first_name\\':\\'Harry\\',\\'id\\':1,\\'ip_address\\':\\'221.25.65.136\\',\\'last_name\\':\\'Riley\\'},{\\'country\\':\\'Tuvalu\\',\\'email\\':\\'[email protected]\\',\\'first_name\\':\\'Bonnie\\',\\'id\\':2,\\'ip_address\\':\\'116.162.43.150\\',\\'last_name\\':\\'Anderson\\'},{\\'country\\':\\'Iraq\\',\\'email\\':\\'[email protected]\\',\\'first_name\\':\\'Marie\\',\\'id\\':3,\\'ip_address\\':\\'181.105.59.57\\',\\'last_name\\':\\'Schmidt\\'},{\\'country\\':\\'Montenegro\\',\\'email\\':\\'[email protected]\\',\\'first_name\\':\\'Phillip\\',\\'id\\':4,\\'ip_address\\':\\'24.223.139.156\\',\\'last_name\\':\\'Willis\\'}]'")

	sorted := "[{\"country\":\"Andorra\",\"email\":\"[email protected]\",\"first_name\":\"Harry\",\"id\":1,\"ip_address\":\"221.25.65.136\",\"last_name\":\"Riley\"},{\"country\":\"Tuvalu\",\"email\":\"[email protected]\",\"first_name\":\"Bonnie\",\"id\":2,\"ip_address\":\"116.162.43.150\",\"last_name\":\"Anderson\"},{\"country\":\"Iraq\",\"email\":\"[email protected]\",\"first_name\":\"Marie\",\"id\":3,\"ip_address\":\"181.105.59.57\",\"last_name\":\"Schmidt\"},{\"country\":\"Montenegro\",\"email\":\"[email protected]\",\"first_name\":\"Phillip\",\"id\":4,\"ip_address\":\"24.223.139.156\",\"last_name\":\"Willis\"}]"
	_ = sorted // Prevent any noused variable errors

	{
		// json.yaml line #37
		/* sorted */
		var expected_ string = sorted
		/* r.json(text).to_json_string() */

		suite.T().Log("About to run line #37: r.JSON(text).ToJSON()")

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

	{
		// json.yaml line #40
		/* err('ReqlQueryLogicError', 'Cannot convert `r.minval` to JSON.') */
		var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.minval` to JSON.")
		/* r.expr(r.minval).to_json_string() */

		suite.T().Log("About to run line #40: r.Expr(r.MinVal).ToJSON()")

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

	{
		// json.yaml line #43
		/* err('ReqlQueryLogicError', 'Cannot convert `r.maxval` to JSON.') */
		var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.maxval` to JSON.")
		/* r.expr(r.maxval).to_json_string() */

		suite.T().Log("About to run line #43: r.Expr(r.MaxVal).ToJSON()")

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

	{
		// json.yaml line #46
		/* err('ReqlQueryLogicError', 'Cannot convert `r.minval` to JSON.') */
		var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.minval` to JSON.")
		/* r.expr(r.minval).coerce_to('string') */

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

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

	{
		// json.yaml line #49
		/* err('ReqlQueryLogicError', 'Cannot convert `r.maxval` to JSON.') */
		var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.maxval` to JSON.")
		/* r.expr(r.maxval).coerce_to('string') */

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

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

	{
		// json.yaml line #52
		/* {'timezone':'+00:00','$reql_type$':'TIME','epoch_time':1410393600} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1410393600}
		/* r.time(2014,9,11, 'Z') */

		suite.T().Log("About to run line #52: r.Time(2014, 9, 11, 'Z')")

		runAndAssert(suite.Suite, expected_, r.Time(2014, 9, 11, "Z"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
			TimeFormat:     "raw",
		})
		suite.T().Log("Finished running line #52")
	}

	{
		// json.yaml line #57
		/* '{"$reql_type$":"TIME","epoch_time":1410393600,"timezone":"+00:00"}' */
		var expected_ string = "{\"$reql_type$\":\"TIME\",\"epoch_time\":1410393600,\"timezone\":\"+00:00\"}"
		/* r.time(2014,9,11, 'Z').to_json_string() */

		suite.T().Log("About to run line #57: r.Time(2014, 9, 11, 'Z').ToJSON()")

		runAndAssert(suite.Suite, expected_, r.Time(2014, 9, 11, "Z").ToJSON(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #57")
	}

	{
		// json.yaml line #60
		/* {'$reql_type$':'GEOMETRY','coordinates':[0,0],'type':'Point'} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{0, 0}, "type": "Point"}
		/* r.point(0,0) */

		suite.T().Log("About to run line #60: r.Point(0, 0)")

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

	{
		// json.yaml line #63
		/* '{"$reql_type$":"GEOMETRY","coordinates":[0,0],"type":"Point"}' */
		var expected_ string = "{\"$reql_type$\":\"GEOMETRY\",\"coordinates\":[0,0],\"type\":\"Point\"}"
		/* r.point(0,0).to_json_string() */

		suite.T().Log("About to run line #63: r.Point(0, 0).ToJSON()")

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

	// json.yaml line #68
	// s = b'\x66\x6f\x6f'
	suite.T().Log("Possibly executing: var s []byte = []byte{102,111,111}")

	s := []byte{102, 111, 111}
	_ = s // Prevent any noused variable errors

	{
		// json.yaml line #70
		/* s */
		var expected_ []byte = s
		/* r.binary(s) */

		suite.T().Log("About to run line #70: r.Binary(s)")

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

	{
		// json.yaml line #73
		/* '{"$reql_type$":"BINARY","data":"Zm9v"}' */
		var expected_ string = "{\"$reql_type$\":\"BINARY\",\"data\":\"Zm9v\"}"
		/* r.expr("foo").coerce_to("binary").to_json_string() */

		suite.T().Log("About to run line #73: r.Expr('foo').CoerceTo('binary').ToJSON()")

		runAndAssert(suite.Suite, expected_, r.Expr("foo").CoerceTo("binary").ToJSON(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #73")
	}
}
Exemplo n.º 2
0
func (suite *TimesApiSuite) TestCases() {
	suite.T().Log("Running TimesApiSuite: date/time api (#977)")

	// times/api.yaml line #6
	// rt1 = 1375147296.6812
	suite.T().Log("Possibly executing: var rt1 float64 = 1375147296.6812")

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

	// times/api.yaml line #7
	// 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/api.yaml line #8
	// t2 = r.epoch_time(rt1 + 1000)
	suite.T().Log("Possibly executing: var t2 r.Term = r.EpochTime(r.Add(rt1, 1000))")

	t2 := r.EpochTime(r.Add(rt1, 1000))
	_ = t2 // Prevent any noused variable errors

	{
		// times/api.yaml line #11
		/* (1375148296.681) */
		var expected_ float64 = 1375148296.681
		/* (t1 + 1000).to_epoch_time() */

		suite.T().Log("About to run line #11: r.Add(t1, 1000).ToEpochTime()")

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

	{
		// times/api.yaml line #14
		/* (1375146296.681) */
		var expected_ float64 = 1375146296.681
		/* (t1 - 1000).to_epoch_time() */

		suite.T().Log("About to run line #14: r.Sub(t1, 1000).ToEpochTime()")

		runAndAssert(suite.Suite, expected_, r.Sub(t1, 1000).ToEpochTime(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #14")
	}

	{
		// times/api.yaml line #17
		/* 1000 */
		var expected_ int = 1000
		/* (t1 - (t1 - 1000)) */

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

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

	{
		// times/api.yaml line #22
		/* false */
		var expected_ bool = false
		/* (t1 < t1) */

		suite.T().Log("About to run line #22: r.Lt(t1, t1)")

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

	{
		// times/api.yaml line #25
		/* true */
		var expected_ bool = true
		/* (t1 <= t1) */

		suite.T().Log("About to run line #25: r.Le(t1, t1)")

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

	{
		// times/api.yaml line #29
		/* true */
		var expected_ bool = true
		/* (t1 == t1) */

		suite.T().Log("About to run line #29: r.Eq(t1, t1)")

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

	{
		// times/api.yaml line #32
		/* false */
		var expected_ bool = false
		/* (t1 != t1) */

		suite.T().Log("About to run line #32: r.Ne(t1, t1)")

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

	{
		// times/api.yaml line #34
		/* true */
		var expected_ bool = true
		/* (t1 >= t1) */

		suite.T().Log("About to run line #34: r.Ge(t1, t1)")

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

	{
		// times/api.yaml line #37
		/* false */
		var expected_ bool = false
		/* (t1 > t1) */

		suite.T().Log("About to run line #37: r.Gt(t1, t1)")

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

	{
		// times/api.yaml line #40
		/* true */
		var expected_ bool = true
		/* (t1 < t2) */

		suite.T().Log("About to run line #40: r.Lt(t1, t2)")

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

	{
		// times/api.yaml line #43
		/* true */
		var expected_ bool = true
		/* (t1 <= t2) */

		suite.T().Log("About to run line #43: r.Le(t1, t2)")

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

	{
		// times/api.yaml line #47
		/* false */
		var expected_ bool = false
		/* (t1 == t2) */

		suite.T().Log("About to run line #47: r.Eq(t1, t2)")

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

	{
		// times/api.yaml line #50
		/* true */
		var expected_ bool = true
		/* (t1 != t2) */

		suite.T().Log("About to run line #50: r.Ne(t1, t2)")

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

	{
		// times/api.yaml line #52
		/* false */
		var expected_ bool = false
		/* (t1 >= t2) */

		suite.T().Log("About to run line #52: r.Ge(t1, t2)")

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

	{
		// times/api.yaml line #55
		/* false */
		var expected_ bool = false
		/* (t1 > t2) */

		suite.T().Log("About to run line #55: r.Gt(t1, t2)")

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

	{
		// times/api.yaml line #60
		/* true */
		var expected_ bool = true
		/* t1.during(t1, t1 + 1000) */

		suite.T().Log("About to run line #60: t1.During(t1, r.Add(t1, 1000))")

		runAndAssert(suite.Suite, expected_, t1.During(t1, r.Add(t1, 1000)), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #60")
	}

	{
		// times/api.yaml line #64
		/* false */
		var expected_ bool = false
		/* t1.during(t1, t1 + 1000, left_bound='open') */

		suite.T().Log("About to run line #64: t1.During(t1, r.Add(t1, 1000)).OptArgs(r.DuringOpts{LeftBound: 'open', })")

		runAndAssert(suite.Suite, expected_, t1.During(t1, r.Add(t1, 1000)).OptArgs(r.DuringOpts{LeftBound: "open"}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #64")
	}

	{
		// times/api.yaml line #67
		/* false */
		var expected_ bool = false
		/* t1.during(t1, t1) */

		suite.T().Log("About to run line #67: t1.During(t1, t1)")

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

	{
		// times/api.yaml line #70
		/* true */
		var expected_ bool = true
		/* t1.during(t1, t1, right_bound='closed') */

		suite.T().Log("About to run line #70: t1.During(t1, t1).OptArgs(r.DuringOpts{RightBound: 'closed', })")

		runAndAssert(suite.Suite, expected_, t1.During(t1, t1).OptArgs(r.DuringOpts{RightBound: "closed"}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #70")
	}

	{
		// times/api.yaml line #77
		/* 1375142400 */
		var expected_ int = 1375142400
		/* t1.date().to_epoch_time() */

		suite.T().Log("About to run line #77: t1.Date().ToEpochTime()")

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

	{
		// times/api.yaml line #79
		/* (4896.681) */
		var expected_ float64 = 4896.681
		/* t1.time_of_day() */

		suite.T().Log("About to run line #79: t1.TimeOfDay()")

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

	{
		// times/api.yaml line #81
		/* 2013 */
		var expected_ int = 2013
		/* t1.year() */

		suite.T().Log("About to run line #81: t1.Year()")

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

	{
		// times/api.yaml line #83
		/* 7 */
		var expected_ int = 7
		/* t1.month() */

		suite.T().Log("About to run line #83: t1.Month()")

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

	{
		// times/api.yaml line #85
		/* 30 */
		var expected_ int = 30
		/* t1.day() */

		suite.T().Log("About to run line #85: t1.Day()")

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

	{
		// times/api.yaml line #87
		/* 2 */
		var expected_ int = 2
		/* t1.day_of_week() */

		suite.T().Log("About to run line #87: t1.DayOfWeek()")

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

	{
		// times/api.yaml line #89
		/* 211 */
		var expected_ int = 211
		/* t1.day_of_year() */

		suite.T().Log("About to run line #89: t1.DayOfYear()")

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

	{
		// times/api.yaml line #91
		/* 1 */
		var expected_ int = 1
		/* t1.hours() */

		suite.T().Log("About to run line #91: t1.Hours()")

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

	{
		// times/api.yaml line #93
		/* 21 */
		var expected_ int = 21
		/* t1.minutes() */

		suite.T().Log("About to run line #93: t1.Minutes()")

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

	{
		// times/api.yaml line #95
		/* 36.681 */
		var expected_ float64 = 36.681
		/* t1.seconds() */

		suite.T().Log("About to run line #95: t1.Seconds()")

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

	{
		// times/api.yaml line #99
		/* (1375165800.1) */
		var expected_ float64 = 1375165800.1
		/* r.time(2013, r.july, 29, 23, 30, 0.1, "-07:00").to_epoch_time() */

		suite.T().Log("About to run line #99: r.Time(2013, r.July, 29, 23, 30, 0.1, '-07:00').ToEpochTime()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1, "-07:00").ToEpochTime(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #99")
	}

	{
		// times/api.yaml line #101
		/* ("-07:00") */
		var expected_ string = "-07:00"
		/* r.time(2013, r.july, 29, 23, 30, 0.1, "-07:00").timezone() */

		suite.T().Log("About to run line #101: r.Time(2013, r.July, 29, 23, 30, 0.1, '-07:00').Timezone()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1, "-07:00").Timezone(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #101")
	}

	{
		// times/api.yaml line #103
		/* err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).", []) */
		var expected_ Err = err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).")
		/* r.time(2013, r.july, 29, 23, 30, 0.1).to_epoch_time() */

		suite.T().Log("About to run line #103: r.Time(2013, r.July, 29, 23, 30, 0.1).ToEpochTime()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1).ToEpochTime(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #103")
	}

	{
		// times/api.yaml line #105
		/* err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).", []) */
		var expected_ Err = err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).")
		/* r.time(2013, r.july, 29, 23, 30, 0.1).timezone() */

		suite.T().Log("About to run line #105: r.Time(2013, r.July, 29, 23, 30, 0.1).Timezone()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1).Timezone(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #105")
	}

	{
		// times/api.yaml line #107
		/* err("ReqlQueryLogicError", "Got 5 arguments to TIME (expected 4 or 7).", []) */
		var expected_ Err = err("ReqlQueryLogicError", "Got 5 arguments to TIME (expected 4 or 7).")
		/* r.time(2013, r.july, 29, 23, 30).to_epoch_time() */

		suite.T().Log("About to run line #107: r.Time(2013, r.July, 29, 23, 30).ToEpochTime()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30).ToEpochTime(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #107")
	}

	{
		// times/api.yaml line #109
		/* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", []) */
		var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.")
		/* r.time(2013, r.july, 29, 23).to_epoch_time() */

		suite.T().Log("About to run line #109: r.Time(2013, r.July, 29, 23).ToEpochTime()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23).ToEpochTime(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #109")
	}

	{
		// times/api.yaml line #111
		/* 1375081200 */
		var expected_ int = 1375081200
		/* r.time(2013, r.july, 29, "-07:00").to_epoch_time() */

		suite.T().Log("About to run line #111: r.Time(2013, r.July, 29, '-07:00').ToEpochTime()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, "-07:00").ToEpochTime(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #111")
	}

	{
		// times/api.yaml line #113
		/* ("-07:00") */
		var expected_ string = "-07:00"
		/* r.time(2013, r.july, 29, "-07:00").timezone() */

		suite.T().Log("About to run line #113: r.Time(2013, r.July, 29, '-07:00').Timezone()")

		runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, "-07:00").Timezone(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #113")
	}

	{
		// times/api.yaml line #119
		/* 1375242965 */
		var expected_ int = 1375242965
		/* r.iso8601("2013-07-30T20:56:05-07:00").to_epoch_time() */

		suite.T().Log("About to run line #119: r.ISO8601('2013-07-30T20:56:05-07:00').ToEpochTime()")

		runAndAssert(suite.Suite, expected_, r.ISO8601("2013-07-30T20:56:05-07:00").ToEpochTime(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #119")
	}

	{
		// times/api.yaml line #122
		/* ("2013-07-30T20:56:05-07:00") */
		var expected_ string = "2013-07-30T20:56:05-07:00"
		/* r.epoch_time(1375242965).in_timezone("-07:00").to_iso8601() */

		suite.T().Log("About to run line #122: r.EpochTime(1375242965).InTimezone('-07:00').ToISO8601()")

		runAndAssert(suite.Suite, expected_, r.EpochTime(1375242965).InTimezone("-07:00").ToISO8601(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #122")
	}

	{
		// times/api.yaml line #125
		/* ("PTYPE<TIME>") */
		var expected_ string = "PTYPE<TIME>"
		/* r.now().type_of() */

		suite.T().Log("About to run line #125: r.Now().TypeOf()")

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

	{
		// times/api.yaml line #127
		/* 0 */
		var expected_ int = 0
		/* (r.now() - r.now()) */

		suite.T().Log("About to run line #127: r.Now().Sub(r.Now())")

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

	{
		// times/api.yaml line #132
		/* err("ReqlQueryLogicError", "ISO 8601 string has no time zone, and no default time zone was provided.", []) */
		var expected_ Err = err("ReqlQueryLogicError", "ISO 8601 string has no time zone, and no default time zone was provided.")
		/* r.iso8601("2013-07-30T20:56:05").to_iso8601() */

		suite.T().Log("About to run line #132: r.ISO8601('2013-07-30T20:56:05').ToISO8601()")

		runAndAssert(suite.Suite, expected_, r.ISO8601("2013-07-30T20:56:05").ToISO8601(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #132")
	}

	{
		// times/api.yaml line #136
		/* ("2013-07-30T20:56:05-07:00") */
		var expected_ string = "2013-07-30T20:56:05-07:00"
		/* r.iso8601("2013-07-30T20:56:05", default_timezone='-07').to_iso8601() */

		suite.T().Log("About to run line #136: r.ISO8601('2013-07-30T20:56:05').OptArgs(r.ISO8601Opts{DefaultTimezone: '-07', }).ToISO8601()")

		runAndAssert(suite.Suite, expected_, r.ISO8601("2013-07-30T20:56:05").OptArgs(r.ISO8601Opts{DefaultTimezone: "-07"}).ToISO8601(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #136")
	}

	{
		// times/api.yaml line #140
		/* ([1, 2, 3, 4, 5, 6, 7]) */
		var expected_ []interface{} = []interface{}{1, 2, 3, 4, 5, 6, 7}
		/* r.expr([r.monday, r.tuesday, r.wednesday, r.thursday, r.friday, r.saturday, r.sunday]) */

		suite.T().Log("About to run line #140: r.Expr([]interface{}{r.Monday, r.Tuesday, r.Wednesday, r.Thursday, r.Friday, r.Saturday, r.Sunday})")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Monday, r.Tuesday, r.Wednesday, r.Thursday, r.Friday, r.Saturday, r.Sunday}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #140")
	}

	{
		// times/api.yaml line #142
		/* ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) */
		var expected_ []interface{} = []interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
		/* r.expr([r.january, r.february, r.march, r.april, r.may, r.june,
		r.july, r.august, r.september, r.october, r.november, r.december]) */

		suite.T().Log("About to run line #142: r.Expr([]interface{}{r.January, r.February, r.March, r.April, r.May, r.June, r.July, r.August, r.September, r.October, r.November, r.December})")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.January, r.February, r.March, r.April, r.May, r.June, r.July, r.August, r.September, r.October, r.November, r.December}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #142")
	}
}
Exemplo n.º 3
0
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

	{
		// times/timezones.yaml line #23
		/* ([["+00:00", 29], ["+00:00", 29], ["+00:00", 29]]) */
		var expected_ []interface{} = []interface{}{[]interface{}{"+00:00", 29}, []interface{}{"+00:00", 29}, []interface{}{"+00:00", 29}}
		/* tutcs.map(lambda x:[x.timezone(), x.day()]) */

		suite.T().Log("About to run line #23: tutcs.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()}})")

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

	{
		// times/timezones.yaml line #27
		/* ([["-00:59", 29], ["-01:00", 29], ["-01:01", 29]]) */
		var expected_ []interface{} = []interface{}{[]interface{}{"-00:59", 29}, []interface{}{"-01:00", 29}, []interface{}{"-01:01", 29}}
		/* tms.map(lambda x:[x.timezone(), x.day()]) */

		suite.T().Log("About to run line #27: tms.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()}})")

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

	{
		// times/timezones.yaml line #31
		/* ([["+00:59", 30], ["+01:00", 30], ["+01:01", 30]]) */
		var expected_ []interface{} = []interface{}{[]interface{}{"+00:59", 30}, []interface{}{"+01:00", 30}, []interface{}{"+01:01", 30}}
		/* tps.map(lambda x:[x.timezone(), x.day()]) */

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

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

	{
		// times/timezones.yaml line #38
		/* ([0]) */
		var expected_ []interface{} = []interface{}{0}
		/* ts.concat_map(lambda x:ts.map(lambda y:x - y)).distinct() */

		suite.T().Log("About to run line #38: ts.ConcatMap(func(x r.Term) interface{} { return ts.Map(func(y r.Term) interface{} { return r.Sub(x, y)})}).Distinct()")

		runAndAssert(suite.Suite, expected_, ts.ConcatMap(func(x r.Term) interface{} { return ts.Map(func(y r.Term) interface{} { return r.Sub(x, y) }) }).Distinct(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #38")
	}

	{
		// times/timezones.yaml line #44
		/* err('ReqlQueryLogicError', 'Timezone `` does not start with `-` or `+`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Timezone `` does not start with `-` or `+`.")
		/* r.now().in_timezone("") */

		suite.T().Log("About to run line #44: r.Now().InTimezone('')")

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

	{
		// times/timezones.yaml line #47
		/* err('ReqlQueryLogicError', '`-00` is not a valid time offset.') */
		var expected_ Err = err("ReqlQueryLogicError", "`-00` is not a valid time offset.")
		/* r.now().in_timezone("-00") */

		suite.T().Log("About to run line #47: r.Now().InTimezone('-00')")

		runAndAssert(suite.Suite, expected_, r.Now().InTimezone("-00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #47")
	}

	{
		// times/timezones.yaml line #50
		/* err('ReqlQueryLogicError', '`-00:00` is not a valid time offset.') */
		var expected_ Err = err("ReqlQueryLogicError", "`-00:00` is not a valid time offset.")
		/* r.now().in_timezone("-00:00") */

		suite.T().Log("About to run line #50: r.Now().InTimezone('-00:00')")

		runAndAssert(suite.Suite, expected_, r.Now().InTimezone("-00:00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #50")
	}

	{
		// times/timezones.yaml line #53
		/* err('ReqlQueryLogicError', 'Timezone `UTC+00` does not start with `-` or `+`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Timezone `UTC+00` does not start with `-` or `+`.")
		/* r.now().in_timezone("UTC+00") */

		suite.T().Log("About to run line #53: r.Now().InTimezone('UTC+00')")

		runAndAssert(suite.Suite, expected_, r.Now().InTimezone("UTC+00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #53")
	}

	{
		// times/timezones.yaml line #56
		/* err('ReqlQueryLogicError', 'Minutes out of range in `+00:60`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Minutes out of range in `+00:60`.")
		/* r.now().in_timezone("+00:60") */

		suite.T().Log("About to run line #56: r.Now().InTimezone('+00:60')")

		runAndAssert(suite.Suite, expected_, r.Now().InTimezone("+00:60"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #56")
	}

	{
		// times/timezones.yaml line #59
		/* err('ReqlQueryLogicError', 'Hours out of range in `+25:00`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Hours out of range in `+25:00`.")
		/* r.now().in_timezone("+25:00") */

		suite.T().Log("About to run line #59: r.Now().InTimezone('+25:00')")

		runAndAssert(suite.Suite, expected_, r.Now().InTimezone("+25:00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #59")
	}

	{
		// times/timezones.yaml line #63
		/* err('ReqlQueryLogicError', 'Timezone `` does not start with `-` or `+`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Timezone `` does not start with `-` or `+`.")
		/* r.time(2013, 1, 1, "") */

		suite.T().Log("About to run line #63: r.Time(2013, 1, 1, '')")

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

	{
		// times/timezones.yaml line #66
		/* err('ReqlQueryLogicError', '`-00` is not a valid time offset.') */
		var expected_ Err = err("ReqlQueryLogicError", "`-00` is not a valid time offset.")
		/* r.time(2013, 1, 1, "-00") */

		suite.T().Log("About to run line #66: r.Time(2013, 1, 1, '-00')")

		runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "-00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #66")
	}

	{
		// times/timezones.yaml line #69
		/* err('ReqlQueryLogicError', '`-00:00` is not a valid time offset.') */
		var expected_ Err = err("ReqlQueryLogicError", "`-00:00` is not a valid time offset.")
		/* r.time(2013, 1, 1, "-00:00") */

		suite.T().Log("About to run line #69: r.Time(2013, 1, 1, '-00:00')")

		runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "-00:00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #69")
	}

	{
		// times/timezones.yaml line #72
		/* err('ReqlQueryLogicError', 'Timezone `UTC+00` does not start with `-` or `+`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Timezone `UTC+00` does not start with `-` or `+`.")
		/* r.time(2013, 1, 1, "UTC+00") */

		suite.T().Log("About to run line #72: r.Time(2013, 1, 1, 'UTC+00')")

		runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "UTC+00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #72")
	}

	{
		// times/timezones.yaml line #75
		/* err('ReqlQueryLogicError', 'Minutes out of range in `+00:60`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Minutes out of range in `+00:60`.")
		/* r.time(2013, 1, 1, "+00:60") */

		suite.T().Log("About to run line #75: r.Time(2013, 1, 1, '+00:60')")

		runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "+00:60"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #75")
	}

	{
		// times/timezones.yaml line #78
		/* err('ReqlQueryLogicError', 'Hours out of range in `+25:00`.') */
		var expected_ Err = err("ReqlQueryLogicError", "Hours out of range in `+25:00`.")
		/* r.time(2013, 1, 1, "+25:00") */

		suite.T().Log("About to run line #78: r.Time(2013, 1, 1, '+25:00')")

		runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "+25:00"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #78")
	}

	{
		// times/timezones.yaml line #81
		/* ("2015-07-08T00:00:00-08:00") */
		var expected_ string = "2015-07-08T00:00:00-08:00"
		/* r.epoch_time(1436428422.339).in_timezone('-08:00').date().to_iso8601() */

		suite.T().Log("About to run line #81: r.EpochTime(1436428422.339).InTimezone('-08:00').Date().ToISO8601()")

		runAndAssert(suite.Suite, expected_, r.EpochTime(1436428422.339).InTimezone("-08:00").Date().ToISO8601(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #81")
	}

	{
		// times/timezones.yaml line #85
		/* ("2015-07-09T00:00:00-07:00") */
		var expected_ string = "2015-07-09T00:00:00-07:00"
		/* r.epoch_time(1436428422.339).in_timezone('-07:00').date().to_iso8601() */

		suite.T().Log("About to run line #85: r.EpochTime(1436428422.339).InTimezone('-07:00').Date().ToISO8601()")

		runAndAssert(suite.Suite, expected_, r.EpochTime(1436428422.339).InTimezone("-07:00").Date().ToISO8601(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #85")
	}
}
Exemplo n.º 4
0
func (suite *TimesPortionsSuite) TestCases() {
	suite.T().Log("Running TimesPortionsSuite: accessing portions")

	// times/portions.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/portions.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/portions.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/portions.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/portions.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/portions.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/portions.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/portions.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/portions.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/portions.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/portions.yaml line #16
		/* ([1375142400, 1375142400, 1375142400, 2375136000]) */
		var expected_ []interface{} = []interface{}{1375142400, 1375142400, 1375142400, 2375136000}
		/* ts.map(lambda x:x.date()).map(lambda x:x.to_epoch_time()) */

		suite.T().Log("About to run line #16: ts.Map(func(x r.Term) interface{} { return x.Date()}).Map(func(x r.Term) interface{} { return x.ToEpochTime()})")

		runAndAssert(suite.Suite, expected_, ts.Map(func(x r.Term) interface{} { return x.Date() }).Map(func(x r.Term) interface{} { return x.ToEpochTime() }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #16")
	}

	{
		// times/portions.yaml line #20
		/* ([0, 0, 0, 0]) */
		var expected_ []interface{} = []interface{}{0, 0, 0, 0}
		/* ts.map(lambda x:x.date().time_of_day()) */

		suite.T().Log("About to run line #20: ts.Map(func(x r.Term) interface{} { return x.Date().TimeOfDay()})")

		runAndAssert(suite.Suite, expected_, ts.Map(func(x r.Term) interface{} { return x.Date().TimeOfDay() }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #20")
	}

	{
		// times/portions.yaml line #24
		/* ([4896.681, 4896.682, 4897.681, 11296.681]) */
		var expected_ []interface{} = []interface{}{4896.681, 4896.682, 4897.681, 11296.681}
		/* ts.map(lambda x:x.time_of_day()) */

		suite.T().Log("About to run line #24: ts.Map(func(x r.Term) interface{} { return x.TimeOfDay()})")

		runAndAssert(suite.Suite, expected_, ts.Map(func(x r.Term) interface{} { return x.TimeOfDay() }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #24")
	}

	{
		// times/portions.yaml line #29
		/* ([[2013, 7, 30, 1, 21, 36.681],
		[2013, 7, 30, 1, 21, 36.682],
		[2013, 7, 30, 1, 21, 37.681],
		[2045, 4, 7, 3, 8, 16.681]]) */
		var expected_ []interface{} = []interface{}{[]interface{}{2013, 7, 30, 1, 21, 36.681}, []interface{}{2013, 7, 30, 1, 21, 36.682}, []interface{}{2013, 7, 30, 1, 21, 37.681}, []interface{}{2045, 4, 7, 3, 8, 16.681}}
		/* ts.map(lambda x:[x.year(), x.month(), x.day(), x.hours(), x.minutes(), x.seconds()]) */

		suite.T().Log("About to run line #29: ts.Map(func(x r.Term) interface{} { return []interface{}{x.Year(), x.Month(), x.Day(), x.Hours(), x.Minutes(), x.Seconds()}})")

		runAndAssert(suite.Suite, expected_, ts.Map(func(x r.Term) interface{} {
			return []interface{}{x.Year(), x.Month(), x.Day(), x.Hours(), x.Minutes(), x.Seconds()}
		}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #29")
	}

	{
		// times/portions.yaml line #36
		/* rts */
		var expected_ []interface{} = rts
		/* ts.map(lambda x:r.time(x.year(), x.month(), x.day(), x.hours(), x.minutes(), x.seconds(), x.timezone())).map(lambda x:x.to_epoch_time()) */

		suite.T().Log("About to run line #36: ts.Map(func(x r.Term) interface{} { return r.Time(x.Year(), x.Month(), x.Day(), x.Hours(), x.Minutes(), x.Seconds(), x.Timezone())}).Map(func(x r.Term) interface{} { return x.ToEpochTime()})")

		runAndAssert(suite.Suite, expected_, ts.Map(func(x r.Term) interface{} {
			return r.Time(x.Year(), x.Month(), x.Day(), x.Hours(), x.Minutes(), x.Seconds(), x.Timezone())
		}).Map(func(x r.Term) interface{} { return x.ToEpochTime() }), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #36")
	}

	{
		// times/portions.yaml line #40
		/* 0 */
		var expected_ int = 0
		/* ts.map(lambda x:r.time(x.year(), x.month(), x.day(), x.hours(), x.minutes(), x.seconds(), x.timezone())).union(ts).map(lambda x:x.to_iso8601()).distinct().count().sub(ts.count()) */

		suite.T().Log("About to run line #40: ts.Map(func(x r.Term) interface{} { return r.Time(x.Year(), x.Month(), x.Day(), x.Hours(), x.Minutes(), x.Seconds(), x.Timezone())}).Union(ts).Map(func(x r.Term) interface{} { return x.ToISO8601()}).Distinct().Count().Sub(ts.Count())")

		runAndAssert(suite.Suite, expected_, ts.Map(func(x r.Term) interface{} {
			return r.Time(x.Year(), x.Month(), x.Day(), x.Hours(), x.Minutes(), x.Seconds(), x.Timezone())
		}).Union(ts).Map(func(x r.Term) interface{} { return x.ToISO8601() }).Distinct().Count().Sub(ts.Count()), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #40")
	}

	{
		// times/portions.yaml line #44
		/* [[2, 211], [2, 211], [2, 211], [5, 97]] */
		var expected_ []interface{} = []interface{}{[]interface{}{2, 211}, []interface{}{2, 211}, []interface{}{2, 211}, []interface{}{5, 97}}
		/* ts.map([r.row.day_of_week(), r.row.day_of_year()]) */

		suite.T().Log("About to run line #44: ts.Map([]interface{}{r.Row.DayOfWeek(), r.Row.DayOfYear()})")

		runAndAssert(suite.Suite, expected_, ts.Map([]interface{}{r.Row.DayOfWeek(), r.Row.DayOfYear()}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #44")
	}
}