gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/internal/integration/reql_tests/reql_datum_array_test.go (about) 1 // Code generated by gen_tests.py and process_polyglot.py. 2 // Do not edit this file directly. 3 // The template for this file is located at: 4 // ../template.go.tpl 5 package reql_tests 6 7 import ( 8 "testing" 9 "time" 10 11 "github.com/stretchr/testify/suite" 12 r "gopkg.in/rethinkdb/rethinkdb-go.v6" 13 "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" 14 ) 15 16 // Tests conversion to and from the RQL array type 17 func TestDatumArraySuite(t *testing.T) { 18 suite.Run(t, new(DatumArraySuite)) 19 } 20 21 type DatumArraySuite struct { 22 suite.Suite 23 24 session *r.Session 25 } 26 27 func (suite *DatumArraySuite) SetupTest() { 28 suite.T().Log("Setting up DatumArraySuite") 29 // Use imports to prevent errors 30 _ = time.Time{} 31 _ = compare.AnythingIsFine 32 33 session, err := r.Connect(r.ConnectOpts{ 34 Address: url, 35 }) 36 suite.Require().NoError(err, "Error returned when connecting to server") 37 suite.session = session 38 39 r.DBDrop("test").Exec(suite.session) 40 err = r.DBCreate("test").Exec(suite.session) 41 suite.Require().NoError(err) 42 err = r.DB("test").Wait().Exec(suite.session) 43 suite.Require().NoError(err) 44 45 } 46 47 func (suite *DatumArraySuite) TearDownSuite() { 48 suite.T().Log("Tearing down DatumArraySuite") 49 50 if suite.session != nil { 51 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) 52 r.DBDrop("test").Exec(suite.session) 53 54 suite.session.Close() 55 } 56 } 57 58 func (suite *DatumArraySuite) TestCases() { 59 suite.T().Log("Running DatumArraySuite: Tests conversion to and from the RQL array type") 60 61 { 62 // datum/array.yaml line #6 63 /* [] */ 64 var expected_ []interface{} = []interface{}{} 65 /* r.expr([]) */ 66 67 suite.T().Log("About to run line #6: r.Expr([]interface{}{})") 68 69 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}), suite.session, r.RunOpts{ 70 GeometryFormat: "raw", 71 GroupFormat: "map", 72 }) 73 suite.T().Log("Finished running line #6") 74 } 75 76 { 77 // datum/array.yaml line #9 78 /* [1] */ 79 var expected_ []interface{} = []interface{}{1} 80 /* r.expr([1]) */ 81 82 suite.T().Log("About to run line #9: r.Expr([]interface{}{1})") 83 84 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1}), suite.session, r.RunOpts{ 85 GeometryFormat: "raw", 86 GroupFormat: "map", 87 }) 88 suite.T().Log("Finished running line #9") 89 } 90 91 { 92 // datum/array.yaml line #14 93 /* [1,2,3,4,5] */ 94 var expected_ []interface{} = []interface{}{1, 2, 3, 4, 5} 95 /* r.expr([1,2,3,4,5]) */ 96 97 suite.T().Log("About to run line #14: r.Expr([]interface{}{1, 2, 3, 4, 5})") 98 99 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4, 5}), suite.session, r.RunOpts{ 100 GeometryFormat: "raw", 101 GroupFormat: "map", 102 }) 103 suite.T().Log("Finished running line #14") 104 } 105 106 { 107 // datum/array.yaml line #19 108 /* 'ARRAY' */ 109 var expected_ string = "ARRAY" 110 /* r.expr([]).type_of() */ 111 112 suite.T().Log("About to run line #19: r.Expr([]interface{}{}).TypeOf()") 113 114 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).TypeOf(), suite.session, r.RunOpts{ 115 GeometryFormat: "raw", 116 GroupFormat: "map", 117 }) 118 suite.T().Log("Finished running line #19") 119 } 120 121 { 122 // datum/array.yaml line #24 123 /* '[1,2]' */ 124 var expected_ string = "[1,2]" 125 /* r.expr([1, 2]).coerce_to('string') */ 126 127 suite.T().Log("About to run line #24: r.Expr([]interface{}{1, 2}).CoerceTo('string')") 128 129 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("string"), suite.session, r.RunOpts{ 130 GeometryFormat: "raw", 131 GroupFormat: "map", 132 }) 133 suite.T().Log("Finished running line #24") 134 } 135 136 { 137 // datum/array.yaml line #25 138 /* '[1,2]' */ 139 var expected_ string = "[1,2]" 140 /* r.expr([1, 2]).coerce_to('STRING') */ 141 142 suite.T().Log("About to run line #25: r.Expr([]interface{}{1, 2}).CoerceTo('STRING')") 143 144 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("STRING"), suite.session, r.RunOpts{ 145 GeometryFormat: "raw", 146 GroupFormat: "map", 147 }) 148 suite.T().Log("Finished running line #25") 149 } 150 151 { 152 // datum/array.yaml line #28 153 /* [1, 2] */ 154 var expected_ []interface{} = []interface{}{1, 2} 155 /* r.expr([1, 2]).coerce_to('array') */ 156 157 suite.T().Log("About to run line #28: r.Expr([]interface{}{1, 2}).CoerceTo('array')") 158 159 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("array"), suite.session, r.RunOpts{ 160 GeometryFormat: "raw", 161 GroupFormat: "map", 162 }) 163 suite.T().Log("Finished running line #28") 164 } 165 166 { 167 // datum/array.yaml line #31 168 /* err('ReqlQueryLogicError', 'Cannot coerce ARRAY to NUMBER.', [0]) */ 169 var expected_ Err = err("ReqlQueryLogicError", "Cannot coerce ARRAY to NUMBER.") 170 /* r.expr([1, 2]).coerce_to('number') */ 171 172 suite.T().Log("About to run line #31: r.Expr([]interface{}{1, 2}).CoerceTo('number')") 173 174 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("number"), suite.session, r.RunOpts{ 175 GeometryFormat: "raw", 176 GroupFormat: "map", 177 }) 178 suite.T().Log("Finished running line #31") 179 } 180 181 { 182 // datum/array.yaml line #34 183 /* {'a':1,'b':2} */ 184 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1, "b": 2} 185 /* r.expr([['a', 1], ['b', 2]]).coerce_to('object') */ 186 187 suite.T().Log("About to run line #34: r.Expr([]interface{}{[]interface{}{'a', 1}, []interface{}{'b', 2}}).CoerceTo('object')") 188 189 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{[]interface{}{"a", 1}, []interface{}{"b", 2}}).CoerceTo("object"), suite.session, r.RunOpts{ 190 GeometryFormat: "raw", 191 GroupFormat: "map", 192 }) 193 suite.T().Log("Finished running line #34") 194 } 195 196 { 197 // datum/array.yaml line #37 198 /* err('ReqlQueryLogicError', 'Expected array of size 2, but got size 0.') */ 199 var expected_ Err = err("ReqlQueryLogicError", "Expected array of size 2, but got size 0.") 200 /* r.expr([[]]).coerce_to('object') */ 201 202 suite.T().Log("About to run line #37: r.Expr([]interface{}{[]interface{}{}}).CoerceTo('object')") 203 204 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{[]interface{}{}}).CoerceTo("object"), suite.session, r.RunOpts{ 205 GeometryFormat: "raw", 206 GroupFormat: "map", 207 }) 208 suite.T().Log("Finished running line #37") 209 } 210 211 { 212 // datum/array.yaml line #40 213 /* err('ReqlQueryLogicError', 'Expected array of size 2, but got size 3.') */ 214 var expected_ Err = err("ReqlQueryLogicError", "Expected array of size 2, but got size 3.") 215 /* r.expr([['1',2,3]]).coerce_to('object') */ 216 217 suite.T().Log("About to run line #40: r.Expr([]interface{}{[]interface{}{'1', 2, 3}}).CoerceTo('object')") 218 219 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{[]interface{}{"1", 2, 3}}).CoerceTo("object"), suite.session, r.RunOpts{ 220 GeometryFormat: "raw", 221 GroupFormat: "map", 222 }) 223 suite.T().Log("Finished running line #40") 224 } 225 226 { 227 // datum/array.yaml line #44 228 /* [1] */ 229 var expected_ []interface{} = []interface{}{1} 230 /* r.expr([r.expr(1)]) */ 231 232 suite.T().Log("About to run line #44: r.Expr([]interface{}{r.Expr(1)})") 233 234 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Expr(1)}), suite.session, r.RunOpts{ 235 GeometryFormat: "raw", 236 GroupFormat: "map", 237 }) 238 suite.T().Log("Finished running line #44") 239 } 240 241 { 242 // datum/array.yaml line #47 243 /* [1,2,3,4] */ 244 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 245 /* r.expr([1,3,4]).insert_at(1, 2) */ 246 247 suite.T().Log("About to run line #47: r.Expr([]interface{}{1, 3, 4}).InsertAt(1, 2)") 248 249 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 3, 4}).InsertAt(1, 2), suite.session, r.RunOpts{ 250 GeometryFormat: "raw", 251 GroupFormat: "map", 252 }) 253 suite.T().Log("Finished running line #47") 254 } 255 256 { 257 // datum/array.yaml line #49 258 /* [1,2,3] */ 259 var expected_ []interface{} = []interface{}{1, 2, 3} 260 /* r.expr([2,3]).insert_at(0, 1) */ 261 262 suite.T().Log("About to run line #49: r.Expr([]interface{}{2, 3}).InsertAt(0, 1)") 263 264 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{2, 3}).InsertAt(0, 1), suite.session, r.RunOpts{ 265 GeometryFormat: "raw", 266 GroupFormat: "map", 267 }) 268 suite.T().Log("Finished running line #49") 269 } 270 271 { 272 // datum/array.yaml line #51 273 /* [1,2,3,4] */ 274 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 275 /* r.expr([1,2,3]).insert_at(-1, 4) */ 276 277 suite.T().Log("About to run line #51: r.Expr([]interface{}{1, 2, 3}).InsertAt(-1, 4)") 278 279 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(-1, 4), suite.session, r.RunOpts{ 280 GeometryFormat: "raw", 281 GroupFormat: "map", 282 }) 283 suite.T().Log("Finished running line #51") 284 } 285 286 { 287 // datum/array.yaml line #53 288 /* [1,2,3,4] */ 289 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 290 /* r.expr([1,2,3]).insert_at(3, 4) */ 291 292 suite.T().Log("About to run line #53: r.Expr([]interface{}{1, 2, 3}).InsertAt(3, 4)") 293 294 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(3, 4), suite.session, r.RunOpts{ 295 GeometryFormat: "raw", 296 GroupFormat: "map", 297 }) 298 suite.T().Log("Finished running line #53") 299 } 300 301 { 302 // datum/array.yaml line #55 303 /* AnythingIsFine */ 304 var expected_ string = compare.AnythingIsFine 305 /* r.expr(3).do(lambda x: r.expr([1,2,3]).insert_at(x, 4)) */ 306 307 suite.T().Log("About to run line #55: r.Expr(3).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).InsertAt(x, 4)})") 308 309 runAndAssert(suite.Suite, expected_, r.Expr(3).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).InsertAt(x, 4) }), suite.session, r.RunOpts{ 310 GeometryFormat: "raw", 311 GroupFormat: "map", 312 }) 313 suite.T().Log("Finished running line #55") 314 } 315 316 { 317 // datum/array.yaml line #59 318 /* err('ReqlNonExistenceError', 'Index `4` out of bounds for array of size: `3`.', [0]) */ 319 var expected_ Err = err("ReqlNonExistenceError", "Index `4` out of bounds for array of size: `3`.") 320 /* r.expr([1,2,3]).insert_at(4, 5) */ 321 322 suite.T().Log("About to run line #59: r.Expr([]interface{}{1, 2, 3}).InsertAt(4, 5)") 323 324 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(4, 5), suite.session, r.RunOpts{ 325 GeometryFormat: "raw", 326 GroupFormat: "map", 327 }) 328 suite.T().Log("Finished running line #59") 329 } 330 331 { 332 // datum/array.yaml line #61 333 /* err('ReqlNonExistenceError', 'Index out of bounds: -5', [0]) */ 334 var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -5") 335 /* r.expr([1,2,3]).insert_at(-5, -1) */ 336 337 suite.T().Log("About to run line #61: r.Expr([]interface{}{1, 2, 3}).InsertAt(-5, -1)") 338 339 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(-5, -1), suite.session, r.RunOpts{ 340 GeometryFormat: "raw", 341 GroupFormat: "map", 342 }) 343 suite.T().Log("Finished running line #61") 344 } 345 346 { 347 // datum/array.yaml line #63 348 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ 349 var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") 350 /* r.expr([1,2,3]).insert_at(1.5, 1) */ 351 352 suite.T().Log("About to run line #63: r.Expr([]interface{}{1, 2, 3}).InsertAt(1.5, 1)") 353 354 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(1.5, 1), suite.session, r.RunOpts{ 355 GeometryFormat: "raw", 356 GroupFormat: "map", 357 }) 358 suite.T().Log("Finished running line #63") 359 } 360 361 { 362 // datum/array.yaml line #65 363 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ 364 var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") 365 /* r.expr([1,2,3]).insert_at(null, 1) */ 366 367 suite.T().Log("About to run line #65: r.Expr([]interface{}{1, 2, 3}).InsertAt(nil, 1)") 368 369 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(nil, 1), suite.session, r.RunOpts{ 370 GeometryFormat: "raw", 371 GroupFormat: "map", 372 }) 373 suite.T().Log("Finished running line #65") 374 } 375 376 { 377 // datum/array.yaml line #68 378 /* [1,2,3,4] */ 379 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 380 /* r.expr([1,4]).splice_at(1, [2,3]) */ 381 382 suite.T().Log("About to run line #68: r.Expr([]interface{}{1, 4}).SpliceAt(1, []interface{}{2, 3})") 383 384 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 4}).SpliceAt(1, []interface{}{2, 3}), suite.session, r.RunOpts{ 385 GeometryFormat: "raw", 386 GroupFormat: "map", 387 }) 388 suite.T().Log("Finished running line #68") 389 } 390 391 { 392 // datum/array.yaml line #70 393 /* [1,2,3,4] */ 394 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 395 /* r.expr([3,4]).splice_at(0, [1,2]) */ 396 397 suite.T().Log("About to run line #70: r.Expr([]interface{}{3, 4}).SpliceAt(0, []interface{}{1, 2})") 398 399 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{3, 4}).SpliceAt(0, []interface{}{1, 2}), suite.session, r.RunOpts{ 400 GeometryFormat: "raw", 401 GroupFormat: "map", 402 }) 403 suite.T().Log("Finished running line #70") 404 } 405 406 { 407 // datum/array.yaml line #72 408 /* [1,2,3,4] */ 409 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 410 /* r.expr([1,2]).splice_at(2, [3,4]) */ 411 412 suite.T().Log("About to run line #72: r.Expr([]interface{}{1, 2}).SpliceAt(2, []interface{}{3, 4})") 413 414 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(2, []interface{}{3, 4}), suite.session, r.RunOpts{ 415 GeometryFormat: "raw", 416 GroupFormat: "map", 417 }) 418 suite.T().Log("Finished running line #72") 419 } 420 421 { 422 // datum/array.yaml line #74 423 /* [1,2,3,4] */ 424 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 425 /* r.expr([1,2]).splice_at(-1, [3,4]) */ 426 427 suite.T().Log("About to run line #74: r.Expr([]interface{}{1, 2}).SpliceAt(-1, []interface{}{3, 4})") 428 429 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(-1, []interface{}{3, 4}), suite.session, r.RunOpts{ 430 GeometryFormat: "raw", 431 GroupFormat: "map", 432 }) 433 suite.T().Log("Finished running line #74") 434 } 435 436 { 437 // datum/array.yaml line #76 438 /* AnythingIsFine */ 439 var expected_ string = compare.AnythingIsFine 440 /* r.expr(2).do(lambda x: r.expr([1,2]).splice_at(x, [3,4])) */ 441 442 suite.T().Log("About to run line #76: r.Expr(2).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2}).SpliceAt(x, []interface{}{3, 4})})") 443 444 runAndAssert(suite.Suite, expected_, r.Expr(2).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2}).SpliceAt(x, []interface{}{3, 4}) }), suite.session, r.RunOpts{ 445 GeometryFormat: "raw", 446 GroupFormat: "map", 447 }) 448 suite.T().Log("Finished running line #76") 449 } 450 451 { 452 // datum/array.yaml line #80 453 /* err('ReqlNonExistenceError', 'Index `3` out of bounds for array of size: `2`.', [0]) */ 454 var expected_ Err = err("ReqlNonExistenceError", "Index `3` out of bounds for array of size: `2`.") 455 /* r.expr([1,2]).splice_at(3, [3,4]) */ 456 457 suite.T().Log("About to run line #80: r.Expr([]interface{}{1, 2}).SpliceAt(3, []interface{}{3, 4})") 458 459 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(3, []interface{}{3, 4}), suite.session, r.RunOpts{ 460 GeometryFormat: "raw", 461 GroupFormat: "map", 462 }) 463 suite.T().Log("Finished running line #80") 464 } 465 466 { 467 // datum/array.yaml line #82 468 /* err('ReqlNonExistenceError', 'Index out of bounds: -4', [0]) */ 469 var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -4") 470 /* r.expr([1,2]).splice_at(-4, [3,4]) */ 471 472 suite.T().Log("About to run line #82: r.Expr([]interface{}{1, 2}).SpliceAt(-4, []interface{}{3, 4})") 473 474 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(-4, []interface{}{3, 4}), suite.session, r.RunOpts{ 475 GeometryFormat: "raw", 476 GroupFormat: "map", 477 }) 478 suite.T().Log("Finished running line #82") 479 } 480 481 { 482 // datum/array.yaml line #84 483 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ 484 var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") 485 /* r.expr([1,2,3]).splice_at(1.5, [1]) */ 486 487 suite.T().Log("About to run line #84: r.Expr([]interface{}{1, 2, 3}).SpliceAt(1.5, []interface{}{1})") 488 489 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).SpliceAt(1.5, []interface{}{1}), suite.session, r.RunOpts{ 490 GeometryFormat: "raw", 491 GroupFormat: "map", 492 }) 493 suite.T().Log("Finished running line #84") 494 } 495 496 { 497 // datum/array.yaml line #86 498 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ 499 var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") 500 /* r.expr([1,2,3]).splice_at(null, [1]) */ 501 502 suite.T().Log("About to run line #86: r.Expr([]interface{}{1, 2, 3}).SpliceAt(nil, []interface{}{1})") 503 504 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).SpliceAt(nil, []interface{}{1}), suite.session, r.RunOpts{ 505 GeometryFormat: "raw", 506 GroupFormat: "map", 507 }) 508 suite.T().Log("Finished running line #86") 509 } 510 511 { 512 // datum/array.yaml line #88 513 /* err('ReqlQueryLogicError', 'Expected type ARRAY but found NUMBER.', [0]) */ 514 var expected_ Err = err("ReqlQueryLogicError", "Expected type ARRAY but found NUMBER.") 515 /* r.expr([1,4]).splice_at(1, 2) */ 516 517 suite.T().Log("About to run line #88: r.Expr([]interface{}{1, 4}).SpliceAt(1, 2)") 518 519 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 4}).SpliceAt(1, 2), suite.session, r.RunOpts{ 520 GeometryFormat: "raw", 521 GroupFormat: "map", 522 }) 523 suite.T().Log("Finished running line #88") 524 } 525 526 { 527 // datum/array.yaml line #91 528 /* [2,3,4] */ 529 var expected_ []interface{} = []interface{}{2, 3, 4} 530 /* r.expr([1,2,3,4]).delete_at(0) */ 531 532 suite.T().Log("About to run line #91: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(0)") 533 534 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(0), suite.session, r.RunOpts{ 535 GeometryFormat: "raw", 536 GroupFormat: "map", 537 }) 538 suite.T().Log("Finished running line #91") 539 } 540 541 { 542 // datum/array.yaml line #93 543 /* AnythingIsFine */ 544 var expected_ string = compare.AnythingIsFine 545 /* r.expr(0).do(lambda x: r.expr([1,2,3,4]).delete_at(x)) */ 546 547 suite.T().Log("About to run line #93: r.Expr(0).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(x)})") 548 549 runAndAssert(suite.Suite, expected_, r.Expr(0).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(x) }), suite.session, r.RunOpts{ 550 GeometryFormat: "raw", 551 GroupFormat: "map", 552 }) 553 suite.T().Log("Finished running line #93") 554 } 555 556 { 557 // datum/array.yaml line #97 558 /* [1,2,3] */ 559 var expected_ []interface{} = []interface{}{1, 2, 3} 560 /* r.expr([1,2,3,4]).delete_at(-1) */ 561 562 suite.T().Log("About to run line #97: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-1)") 563 564 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-1), suite.session, r.RunOpts{ 565 GeometryFormat: "raw", 566 GroupFormat: "map", 567 }) 568 suite.T().Log("Finished running line #97") 569 } 570 571 { 572 // datum/array.yaml line #99 573 /* [1,4] */ 574 var expected_ []interface{} = []interface{}{1, 4} 575 /* r.expr([1,2,3,4]).delete_at(1,3) */ 576 577 suite.T().Log("About to run line #99: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, 3)") 578 579 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, 3), suite.session, r.RunOpts{ 580 GeometryFormat: "raw", 581 GroupFormat: "map", 582 }) 583 suite.T().Log("Finished running line #99") 584 } 585 586 { 587 // datum/array.yaml line #101 588 /* [1,2,3,4] */ 589 var expected_ []interface{} = []interface{}{1, 2, 3, 4} 590 /* r.expr([1,2,3,4]).delete_at(4,4) */ 591 592 suite.T().Log("About to run line #101: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4, 4)") 593 594 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4, 4), suite.session, r.RunOpts{ 595 GeometryFormat: "raw", 596 GroupFormat: "map", 597 }) 598 suite.T().Log("Finished running line #101") 599 } 600 601 { 602 // datum/array.yaml line #103 603 /* [] */ 604 var expected_ []interface{} = []interface{}{} 605 /* r.expr([]).delete_at(0,0) */ 606 607 suite.T().Log("About to run line #103: r.Expr([]interface{}{}).DeleteAt(0, 0)") 608 609 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).DeleteAt(0, 0), suite.session, r.RunOpts{ 610 GeometryFormat: "raw", 611 GroupFormat: "map", 612 }) 613 suite.T().Log("Finished running line #103") 614 } 615 616 { 617 // datum/array.yaml line #105 618 /* [1,4] */ 619 var expected_ []interface{} = []interface{}{1, 4} 620 /* r.expr([1,2,3,4]).delete_at(1,-1) */ 621 622 suite.T().Log("About to run line #105: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, -1)") 623 624 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, -1), suite.session, r.RunOpts{ 625 GeometryFormat: "raw", 626 GroupFormat: "map", 627 }) 628 suite.T().Log("Finished running line #105") 629 } 630 631 { 632 // datum/array.yaml line #107 633 /* err('ReqlNonExistenceError', 'Index `4` out of bounds for array of size: `4`.', [0]) */ 634 var expected_ Err = err("ReqlNonExistenceError", "Index `4` out of bounds for array of size: `4`.") 635 /* r.expr([1,2,3,4]).delete_at(4) */ 636 637 suite.T().Log("About to run line #107: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4)") 638 639 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4), suite.session, r.RunOpts{ 640 GeometryFormat: "raw", 641 GroupFormat: "map", 642 }) 643 suite.T().Log("Finished running line #107") 644 } 645 646 { 647 // datum/array.yaml line #109 648 /* err('ReqlNonExistenceError', 'Index out of bounds: -5', [0]) */ 649 var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -5") 650 /* r.expr([1,2,3,4]).delete_at(-5) */ 651 652 suite.T().Log("About to run line #109: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-5)") 653 654 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-5), suite.session, r.RunOpts{ 655 GeometryFormat: "raw", 656 GroupFormat: "map", 657 }) 658 suite.T().Log("Finished running line #109") 659 } 660 661 { 662 // datum/array.yaml line #111 663 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ 664 var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") 665 /* r.expr([1,2,3]).delete_at(1.5) */ 666 667 suite.T().Log("About to run line #111: r.Expr([]interface{}{1, 2, 3}).DeleteAt(1.5)") 668 669 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).DeleteAt(1.5), suite.session, r.RunOpts{ 670 GeometryFormat: "raw", 671 GroupFormat: "map", 672 }) 673 suite.T().Log("Finished running line #111") 674 } 675 676 { 677 // datum/array.yaml line #113 678 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ 679 var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") 680 /* r.expr([1,2,3]).delete_at(null) */ 681 682 suite.T().Log("About to run line #113: r.Expr([]interface{}{1, 2, 3}).DeleteAt(nil)") 683 684 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).DeleteAt(nil), suite.session, r.RunOpts{ 685 GeometryFormat: "raw", 686 GroupFormat: "map", 687 }) 688 suite.T().Log("Finished running line #113") 689 } 690 691 { 692 // datum/array.yaml line #116 693 /* [1,2,3] */ 694 var expected_ []interface{} = []interface{}{1, 2, 3} 695 /* r.expr([0,2,3]).change_at(0, 1) */ 696 697 suite.T().Log("About to run line #116: r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, 1)") 698 699 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, 1), suite.session, r.RunOpts{ 700 GeometryFormat: "raw", 701 GroupFormat: "map", 702 }) 703 suite.T().Log("Finished running line #116") 704 } 705 706 { 707 // datum/array.yaml line #118 708 /* AnythingIsFine */ 709 var expected_ string = compare.AnythingIsFine 710 /* r.expr(1).do(lambda x: r.expr([0,2,3]).change_at(0,x)) */ 711 712 suite.T().Log("About to run line #118: r.Expr(1).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, x)})") 713 714 runAndAssert(suite.Suite, expected_, r.Expr(1).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, x) }), suite.session, r.RunOpts{ 715 GeometryFormat: "raw", 716 GroupFormat: "map", 717 }) 718 suite.T().Log("Finished running line #118") 719 } 720 721 { 722 // datum/array.yaml line #122 723 /* [1,2,3] */ 724 var expected_ []interface{} = []interface{}{1, 2, 3} 725 /* r.expr([1,0,3]).change_at(1, 2) */ 726 727 suite.T().Log("About to run line #122: r.Expr([]interface{}{1, 0, 3}).ChangeAt(1, 2)") 728 729 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 0, 3}).ChangeAt(1, 2), suite.session, r.RunOpts{ 730 GeometryFormat: "raw", 731 GroupFormat: "map", 732 }) 733 suite.T().Log("Finished running line #122") 734 } 735 736 { 737 // datum/array.yaml line #124 738 /* [1,2,3] */ 739 var expected_ []interface{} = []interface{}{1, 2, 3} 740 /* r.expr([1,2,0]).change_at(2, 3) */ 741 742 suite.T().Log("About to run line #124: r.Expr([]interface{}{1, 2, 0}).ChangeAt(2, 3)") 743 744 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 0}).ChangeAt(2, 3), suite.session, r.RunOpts{ 745 GeometryFormat: "raw", 746 GroupFormat: "map", 747 }) 748 suite.T().Log("Finished running line #124") 749 } 750 751 { 752 // datum/array.yaml line #126 753 /* err('ReqlNonExistenceError', 'Index `3` out of bounds for array of size: `3`.', [0]) */ 754 var expected_ Err = err("ReqlNonExistenceError", "Index `3` out of bounds for array of size: `3`.") 755 /* r.expr([1,2,3]).change_at(3, 4) */ 756 757 suite.T().Log("About to run line #126: r.Expr([]interface{}{1, 2, 3}).ChangeAt(3, 4)") 758 759 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ChangeAt(3, 4), suite.session, r.RunOpts{ 760 GeometryFormat: "raw", 761 GroupFormat: "map", 762 }) 763 suite.T().Log("Finished running line #126") 764 } 765 766 { 767 // datum/array.yaml line #128 768 /* err('ReqlNonExistenceError', 'Index out of bounds: -5', [0]) */ 769 var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -5") 770 /* r.expr([1,2,3,4]).change_at(-5, 1) */ 771 772 suite.T().Log("About to run line #128: r.Expr([]interface{}{1, 2, 3, 4}).ChangeAt(-5, 1)") 773 774 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).ChangeAt(-5, 1), suite.session, r.RunOpts{ 775 GeometryFormat: "raw", 776 GroupFormat: "map", 777 }) 778 suite.T().Log("Finished running line #128") 779 } 780 781 { 782 // datum/array.yaml line #130 783 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ 784 var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") 785 /* r.expr([1,2,3]).change_at(1.5, 1) */ 786 787 suite.T().Log("About to run line #130: r.Expr([]interface{}{1, 2, 3}).ChangeAt(1.5, 1)") 788 789 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ChangeAt(1.5, 1), suite.session, r.RunOpts{ 790 GeometryFormat: "raw", 791 GroupFormat: "map", 792 }) 793 suite.T().Log("Finished running line #130") 794 } 795 796 { 797 // datum/array.yaml line #132 798 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ 799 var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") 800 /* r.expr([1,2,3]).change_at(null, 1) */ 801 802 suite.T().Log("About to run line #132: r.Expr([]interface{}{1, 2, 3}).ChangeAt(nil, 1)") 803 804 runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ChangeAt(nil, 1), suite.session, r.RunOpts{ 805 GeometryFormat: "raw", 806 GroupFormat: "map", 807 }) 808 suite.T().Log("Finished running line #132") 809 } 810 }