| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 EXPECT_VALID(result); | 294 EXPECT_VALID(result); |
| 295 EXPECT(fits); | 295 EXPECT(fits); |
| 296 | 296 |
| 297 Dart_Handle val3 = Dart_NewIntegerFromHexCString(kIntegerVal3); | 297 Dart_Handle val3 = Dart_NewIntegerFromHexCString(kIntegerVal3); |
| 298 EXPECT(Dart_IsInteger(val3)); | 298 EXPECT(Dart_IsInteger(val3)); |
| 299 result = Dart_IntegerFitsIntoInt64(val3, &fits); | 299 result = Dart_IntegerFitsIntoInt64(val3, &fits); |
| 300 EXPECT_VALID(result); | 300 EXPECT_VALID(result); |
| 301 EXPECT(!fits); | 301 EXPECT(!fits); |
| 302 | 302 |
| 303 int64_t out = 0; | 303 int64_t out = 0; |
| 304 result = Dart_IntegerValue(val1, &out); | 304 result = Dart_IntegerToInt64(val1, &out); |
| 305 EXPECT_VALID(result); | 305 EXPECT_VALID(result); |
| 306 EXPECT_EQ(kIntegerVal1, out); | 306 EXPECT_EQ(kIntegerVal1, out); |
| 307 | 307 |
| 308 result = Dart_IntegerValue(val2, &out); | 308 result = Dart_IntegerToInt64(val2, &out); |
| 309 EXPECT_VALID(result); | 309 EXPECT_VALID(result); |
| 310 EXPECT_EQ(kIntegerVal2, out); | 310 EXPECT_EQ(kIntegerVal2, out); |
| 311 | 311 |
| 312 const char* chars = NULL; | 312 const char* chars = NULL; |
| 313 result = Dart_IntegerValueHexCString(val3, &chars); | 313 result = Dart_IntegerToHexCString(val3, &chars); |
| 314 EXPECT_VALID(result); | 314 EXPECT_VALID(result); |
| 315 EXPECT(!strcmp(kIntegerVal3, chars)); | 315 EXPECT(!strcmp(kIntegerVal3, chars)); |
| 316 } | 316 } |
| 317 | 317 |
| 318 | 318 |
| 319 UNIT_TEST_CASE(IntegerFitsIntoInt64) { |
| 320 TestIsolateScope __test_isolate__; |
| 321 |
| 322 Dart_Handle max = Dart_NewInteger(DART_INT64_C(0x7FFFFFFFFFFFFFFF)); |
| 323 EXPECT(Dart_IsInteger(max)); |
| 324 bool fits = false; |
| 325 Dart_Handle result = Dart_IntegerFitsIntoInt64(max, &fits); |
| 326 EXPECT_VALID(result); |
| 327 EXPECT(fits); |
| 328 |
| 329 Dart_Handle above_max = Dart_NewIntegerFromHexCString("0x8000000000000000"); |
| 330 EXPECT(Dart_IsInteger(above_max)); |
| 331 fits = true; |
| 332 result = Dart_IntegerFitsIntoInt64(above_max, &fits); |
| 333 EXPECT_VALID(result); |
| 334 EXPECT(!fits); |
| 335 |
| 336 Dart_Handle min = Dart_NewInteger(DART_INT64_C(-0x8000000000000000)); |
| 337 EXPECT(Dart_IsInteger(min)); |
| 338 fits = false; |
| 339 result = Dart_IntegerFitsIntoInt64(min, &fits); |
| 340 EXPECT_VALID(result); |
| 341 EXPECT(fits); |
| 342 |
| 343 Dart_Handle below_min = Dart_NewIntegerFromHexCString("-0x8000000000000001"); |
| 344 EXPECT(Dart_IsInteger(below_min)); |
| 345 fits = true; |
| 346 result = Dart_IntegerFitsIntoInt64(below_min, &fits); |
| 347 EXPECT_VALID(result); |
| 348 EXPECT(!fits); |
| 349 } |
| 350 |
| 351 |
| 352 UNIT_TEST_CASE(IntegerFitsIntoUint64) { |
| 353 TestIsolateScope __test_isolate__; |
| 354 |
| 355 Dart_Handle max = Dart_NewIntegerFromHexCString("0xFFFFFFFFFFFFFFFF"); |
| 356 EXPECT(Dart_IsInteger(max)); |
| 357 bool fits = false; |
| 358 Dart_Handle result = Dart_IntegerFitsIntoUint64(max, &fits); |
| 359 EXPECT_VALID(result); |
| 360 EXPECT(fits); |
| 361 |
| 362 Dart_Handle above_max = Dart_NewIntegerFromHexCString("0x10000000000000000"); |
| 363 EXPECT(Dart_IsInteger(above_max)); |
| 364 fits = true; |
| 365 result = Dart_IntegerFitsIntoUint64(above_max, &fits); |
| 366 EXPECT_VALID(result); |
| 367 EXPECT(!fits); |
| 368 |
| 369 Dart_Handle min = Dart_NewInteger(0); |
| 370 EXPECT(Dart_IsInteger(min)); |
| 371 fits = false; |
| 372 result = Dart_IntegerFitsIntoUint64(min, &fits); |
| 373 EXPECT_VALID(result); |
| 374 EXPECT(fits); |
| 375 |
| 376 Dart_Handle below_min = Dart_NewIntegerFromHexCString("-1"); |
| 377 EXPECT(Dart_IsInteger(below_min)); |
| 378 fits = true; |
| 379 result = Dart_IntegerFitsIntoUint64(below_min, &fits); |
| 380 EXPECT_VALID(result); |
| 381 EXPECT(!fits); |
| 382 } |
| 383 |
| 384 |
| 319 UNIT_TEST_CASE(ArrayValues) { | 385 UNIT_TEST_CASE(ArrayValues) { |
| 320 TestIsolateScope __test_isolate__; | 386 TestIsolateScope __test_isolate__; |
| 321 | 387 |
| 322 const int kArrayLength = 10; | 388 const int kArrayLength = 10; |
| 323 Dart_Handle str = Dart_NewString("test"); | 389 Dart_Handle str = Dart_NewString("test"); |
| 324 EXPECT(!Dart_IsList(str)); | 390 EXPECT(!Dart_IsList(str)); |
| 325 Dart_Handle val = Dart_NewList(kArrayLength); | 391 Dart_Handle val = Dart_NewList(kArrayLength); |
| 326 EXPECT(Dart_IsList(val)); | 392 EXPECT(Dart_IsList(val)); |
| 327 intptr_t len = 0; | 393 intptr_t len = 0; |
| 328 Dart_Handle result = Dart_ListLength(val, &len); | 394 Dart_Handle result = Dart_ListLength(val, &len); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 340 EXPECT(Dart_IsError(result)); | 406 EXPECT(Dart_IsError(result)); |
| 341 | 407 |
| 342 for (int i = 0; i < kArrayLength; i++) { | 408 for (int i = 0; i < kArrayLength; i++) { |
| 343 result = Dart_ListSetAt(val, i, Dart_NewInteger(i)); | 409 result = Dart_ListSetAt(val, i, Dart_NewInteger(i)); |
| 344 EXPECT_VALID(result); | 410 EXPECT_VALID(result); |
| 345 } | 411 } |
| 346 for (int i = 0; i < kArrayLength; i++) { | 412 for (int i = 0; i < kArrayLength; i++) { |
| 347 result = Dart_ListGetAt(val, i); | 413 result = Dart_ListGetAt(val, i); |
| 348 EXPECT_VALID(result); | 414 EXPECT_VALID(result); |
| 349 int64_t value; | 415 int64_t value; |
| 350 result = Dart_IntegerValue(result, &value); | 416 result = Dart_IntegerToInt64(result, &value); |
| 351 EXPECT_VALID(result); | 417 EXPECT_VALID(result); |
| 352 EXPECT_EQ(i, value); | 418 EXPECT_EQ(i, value); |
| 353 } | 419 } |
| 354 } | 420 } |
| 355 | 421 |
| 356 | 422 |
| 357 UNIT_TEST_CASE(IsString) { | 423 UNIT_TEST_CASE(IsString) { |
| 358 TestIsolateScope __test_isolate__; | 424 TestIsolateScope __test_isolate__; |
| 359 | 425 |
| 360 uint8_t data8[] = { 'o', 'n', 'e', 0xFF }; | 426 uint8_t data8[] = { 'o', 'n', 'e', 0xFF }; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 intptr_t len = 0; | 557 intptr_t len = 0; |
| 492 result = Dart_ListLength(ListAccessTestObj, &len); | 558 result = Dart_ListLength(ListAccessTestObj, &len); |
| 493 EXPECT_VALID(result); | 559 EXPECT_VALID(result); |
| 494 EXPECT_EQ(3, len); | 560 EXPECT_EQ(3, len); |
| 495 | 561 |
| 496 // Access elements in the array. | 562 // Access elements in the array. |
| 497 int64_t value; | 563 int64_t value; |
| 498 | 564 |
| 499 result = Dart_ListGetAt(ListAccessTestObj, 0); | 565 result = Dart_ListGetAt(ListAccessTestObj, 0); |
| 500 EXPECT_VALID(result); | 566 EXPECT_VALID(result); |
| 501 result = Dart_IntegerValue(result, &value); | 567 result = Dart_IntegerToInt64(result, &value); |
| 502 EXPECT_VALID(result); | 568 EXPECT_VALID(result); |
| 503 EXPECT_EQ(10, value); | 569 EXPECT_EQ(10, value); |
| 504 | 570 |
| 505 result = Dart_ListGetAt(ListAccessTestObj, 1); | 571 result = Dart_ListGetAt(ListAccessTestObj, 1); |
| 506 EXPECT_VALID(result); | 572 EXPECT_VALID(result); |
| 507 result = Dart_IntegerValue(result, &value); | 573 result = Dart_IntegerToInt64(result, &value); |
| 508 EXPECT_VALID(result); | 574 EXPECT_VALID(result); |
| 509 EXPECT_EQ(20, value); | 575 EXPECT_EQ(20, value); |
| 510 | 576 |
| 511 result = Dart_ListGetAt(ListAccessTestObj, 2); | 577 result = Dart_ListGetAt(ListAccessTestObj, 2); |
| 512 EXPECT_VALID(result); | 578 EXPECT_VALID(result); |
| 513 result = Dart_IntegerValue(result, &value); | 579 result = Dart_IntegerToInt64(result, &value); |
| 514 EXPECT_VALID(result); | 580 EXPECT_VALID(result); |
| 515 EXPECT_EQ(30, value); | 581 EXPECT_EQ(30, value); |
| 516 | 582 |
| 517 // Set some elements in the array. | 583 // Set some elements in the array. |
| 518 result = Dart_ListSetAt(ListAccessTestObj, 0, Dart_NewInteger(0)); | 584 result = Dart_ListSetAt(ListAccessTestObj, 0, Dart_NewInteger(0)); |
| 519 EXPECT_VALID(result); | 585 EXPECT_VALID(result); |
| 520 result = Dart_ListSetAt(ListAccessTestObj, 1, Dart_NewInteger(1)); | 586 result = Dart_ListSetAt(ListAccessTestObj, 1, Dart_NewInteger(1)); |
| 521 EXPECT_VALID(result); | 587 EXPECT_VALID(result); |
| 522 result = Dart_ListSetAt(ListAccessTestObj, 2, Dart_NewInteger(2)); | 588 result = Dart_ListSetAt(ListAccessTestObj, 2, Dart_NewInteger(2)); |
| 523 EXPECT_VALID(result); | 589 EXPECT_VALID(result); |
| 524 | 590 |
| 525 // Get length of array object. | 591 // Get length of array object. |
| 526 result = Dart_ListLength(ListAccessTestObj, &len); | 592 result = Dart_ListLength(ListAccessTestObj, &len); |
| 527 EXPECT_VALID(result); | 593 EXPECT_VALID(result); |
| 528 EXPECT_EQ(3, len); | 594 EXPECT_EQ(3, len); |
| 529 | 595 |
| 530 // Now try and access these elements in the array. | 596 // Now try and access these elements in the array. |
| 531 result = Dart_ListGetAt(ListAccessTestObj, 0); | 597 result = Dart_ListGetAt(ListAccessTestObj, 0); |
| 532 EXPECT_VALID(result); | 598 EXPECT_VALID(result); |
| 533 result = Dart_IntegerValue(result, &value); | 599 result = Dart_IntegerToInt64(result, &value); |
| 534 EXPECT_VALID(result); | 600 EXPECT_VALID(result); |
| 535 EXPECT_EQ(0, value); | 601 EXPECT_EQ(0, value); |
| 536 | 602 |
| 537 result = Dart_ListGetAt(ListAccessTestObj, 1); | 603 result = Dart_ListGetAt(ListAccessTestObj, 1); |
| 538 EXPECT_VALID(result); | 604 EXPECT_VALID(result); |
| 539 result = Dart_IntegerValue(result, &value); | 605 result = Dart_IntegerToInt64(result, &value); |
| 540 EXPECT_VALID(result); | 606 EXPECT_VALID(result); |
| 541 EXPECT_EQ(1, value); | 607 EXPECT_EQ(1, value); |
| 542 | 608 |
| 543 result = Dart_ListGetAt(ListAccessTestObj, 2); | 609 result = Dart_ListGetAt(ListAccessTestObj, 2); |
| 544 EXPECT_VALID(result); | 610 EXPECT_VALID(result); |
| 545 result = Dart_IntegerValue(result, &value); | 611 result = Dart_IntegerToInt64(result, &value); |
| 546 EXPECT_VALID(result); | 612 EXPECT_VALID(result); |
| 547 EXPECT_EQ(2, value); | 613 EXPECT_EQ(2, value); |
| 548 | 614 |
| 549 uint8_t native_array[3]; | 615 uint8_t native_array[3]; |
| 550 result = Dart_ListGetAsBytes(ListAccessTestObj, 0, native_array, 3); | 616 result = Dart_ListGetAsBytes(ListAccessTestObj, 0, native_array, 3); |
| 551 EXPECT_VALID(result); | 617 EXPECT_VALID(result); |
| 552 EXPECT_EQ(0, native_array[0]); | 618 EXPECT_EQ(0, native_array[0]); |
| 553 EXPECT_EQ(1, native_array[1]); | 619 EXPECT_EQ(1, native_array[1]); |
| 554 EXPECT_EQ(2, native_array[2]); | 620 EXPECT_EQ(2, native_array[2]); |
| 555 | 621 |
| 556 native_array[0] = 10; | 622 native_array[0] = 10; |
| 557 native_array[1] = 20; | 623 native_array[1] = 20; |
| 558 native_array[2] = 30; | 624 native_array[2] = 30; |
| 559 result = Dart_ListSetAsBytes(ListAccessTestObj, 0, native_array, 3); | 625 result = Dart_ListSetAsBytes(ListAccessTestObj, 0, native_array, 3); |
| 560 EXPECT_VALID(result); | 626 EXPECT_VALID(result); |
| 561 result = Dart_ListGetAsBytes(ListAccessTestObj, 0, native_array, 3); | 627 result = Dart_ListGetAsBytes(ListAccessTestObj, 0, native_array, 3); |
| 562 EXPECT_VALID(result); | 628 EXPECT_VALID(result); |
| 563 EXPECT_EQ(10, native_array[0]); | 629 EXPECT_EQ(10, native_array[0]); |
| 564 EXPECT_EQ(20, native_array[1]); | 630 EXPECT_EQ(20, native_array[1]); |
| 565 EXPECT_EQ(30, native_array[2]); | 631 EXPECT_EQ(30, native_array[2]); |
| 566 result = Dart_ListGetAt(ListAccessTestObj, 2); | 632 result = Dart_ListGetAt(ListAccessTestObj, 2); |
| 567 EXPECT_VALID(result); | 633 EXPECT_VALID(result); |
| 568 result = Dart_IntegerValue(result, &value); | 634 result = Dart_IntegerToInt64(result, &value); |
| 569 EXPECT_VALID(result); | 635 EXPECT_VALID(result); |
| 570 EXPECT_EQ(30, value); | 636 EXPECT_EQ(30, value); |
| 571 | 637 |
| 572 // Check if we get an exception when accessing beyond limit. | 638 // Check if we get an exception when accessing beyond limit. |
| 573 result = Dart_ListGetAt(ListAccessTestObj, 4); | 639 result = Dart_ListGetAt(ListAccessTestObj, 4); |
| 574 EXPECT(Dart_IsError(result)); | 640 EXPECT(Dart_IsError(result)); |
| 575 } | 641 } |
| 576 } | 642 } |
| 577 | 643 |
| 578 #endif // TARGET_ARCH_IA32. | 644 #endif // TARGET_ARCH_IA32. |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 // Now access and set various static fields of Fields class. | 959 // Now access and set various static fields of Fields class. |
| 894 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("Fields")); | 960 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("Fields")); |
| 895 EXPECT_VALID(cls); | 961 EXPECT_VALID(cls); |
| 896 result = Dart_GetStaticField(cls, Dart_NewString("fld1")); | 962 result = Dart_GetStaticField(cls, Dart_NewString("fld1")); |
| 897 EXPECT(Dart_IsError(result)); | 963 EXPECT(Dart_IsError(result)); |
| 898 result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); | 964 result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); |
| 899 EXPECT(Dart_IsError(result)); | 965 EXPECT(Dart_IsError(result)); |
| 900 result = Dart_GetStaticField(cls, Dart_NewString("fld4")); | 966 result = Dart_GetStaticField(cls, Dart_NewString("fld4")); |
| 901 EXPECT_VALID(result); | 967 EXPECT_VALID(result); |
| 902 int64_t value = 0; | 968 int64_t value = 0; |
| 903 result = Dart_IntegerValue(result, &value); | 969 result = Dart_IntegerToInt64(result, &value); |
| 904 EXPECT_EQ(10, value); | 970 EXPECT_EQ(10, value); |
| 905 result = Dart_SetStaticField(cls, | 971 result = Dart_SetStaticField(cls, |
| 906 Dart_NewString("fld4"), | 972 Dart_NewString("fld4"), |
| 907 Dart_NewInteger(20)); | 973 Dart_NewInteger(20)); |
| 908 EXPECT(Dart_IsError(result)); | 974 EXPECT(Dart_IsError(result)); |
| 909 result = Dart_GetStaticField(cls, Dart_NewString("fld3")); | 975 result = Dart_GetStaticField(cls, Dart_NewString("fld3")); |
| 910 EXPECT_VALID(result); | 976 EXPECT_VALID(result); |
| 911 result = Dart_SetStaticField(cls, | 977 result = Dart_SetStaticField(cls, |
| 912 Dart_NewString("fld3"), | 978 Dart_NewString("fld3"), |
| 913 Dart_NewInteger(200)); | 979 Dart_NewInteger(200)); |
| 914 EXPECT_VALID(result); | 980 EXPECT_VALID(result); |
| 915 result = Dart_IntegerValue(result, &value); | 981 result = Dart_IntegerToInt64(result, &value); |
| 916 EXPECT_EQ(200, value); | 982 EXPECT_EQ(200, value); |
| 917 | 983 |
| 918 // Now access and set various instance fields of the returned object. | 984 // Now access and set various instance fields of the returned object. |
| 919 result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); | 985 result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); |
| 920 EXPECT(Dart_IsError(result)); | 986 EXPECT(Dart_IsError(result)); |
| 921 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); | 987 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); |
| 922 EXPECT_VALID(result); | 988 EXPECT_VALID(result); |
| 923 result = Dart_IntegerValue(result, &value); | 989 result = Dart_IntegerToInt64(result, &value); |
| 924 EXPECT_EQ(10, value); | 990 EXPECT_EQ(10, value); |
| 925 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); | 991 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); |
| 926 EXPECT_VALID(result); | 992 EXPECT_VALID(result); |
| 927 result = Dart_IntegerValue(result, &value); | 993 result = Dart_IntegerToInt64(result, &value); |
| 928 EXPECT_EQ(20, value); | 994 EXPECT_EQ(20, value); |
| 929 result = Dart_SetInstanceField(retobj, | 995 result = Dart_SetInstanceField(retobj, |
| 930 Dart_NewString("fld2"), | 996 Dart_NewString("fld2"), |
| 931 Dart_NewInteger(40)); | 997 Dart_NewInteger(40)); |
| 932 EXPECT(Dart_IsError(result)); | 998 EXPECT(Dart_IsError(result)); |
| 933 result = Dart_SetInstanceField(retobj, | 999 result = Dart_SetInstanceField(retobj, |
| 934 Dart_NewString("fld1"), | 1000 Dart_NewString("fld1"), |
| 935 Dart_NewInteger(40)); | 1001 Dart_NewInteger(40)); |
| 936 EXPECT_VALID(result); | 1002 EXPECT_VALID(result); |
| 937 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); | 1003 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); |
| 938 EXPECT_VALID(result); | 1004 EXPECT_VALID(result); |
| 939 result = Dart_IntegerValue(result, &value); | 1005 result = Dart_IntegerToInt64(result, &value); |
| 940 EXPECT_EQ(40, value); | 1006 EXPECT_EQ(40, value); |
| 941 } | 1007 } |
| 942 } | 1008 } |
| 943 | 1009 |
| 944 | 1010 |
| 945 UNIT_TEST_CASE(HiddenFieldAccess) { | 1011 UNIT_TEST_CASE(HiddenFieldAccess) { |
| 946 const char* kScriptChars = | 1012 const char* kScriptChars = |
| 947 "class HiddenFields {\n" | 1013 "class HiddenFields {\n" |
| 948 " HiddenFields(int i, int j) : _fld1 = i, _fld2 = j {}\n" | 1014 " HiddenFields(int i, int j) : _fld1 = i, _fld2 = j {}\n" |
| 949 " int _fld1;\n" | 1015 " int _fld1;\n" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 975 // Now access and set various static fields of HiddenFields class. | 1041 // Now access and set various static fields of HiddenFields class. |
| 976 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("HiddenFields")); | 1042 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("HiddenFields")); |
| 977 EXPECT_VALID(cls); | 1043 EXPECT_VALID(cls); |
| 978 result = Dart_GetStaticField(cls, Dart_NewString("_fld1")); | 1044 result = Dart_GetStaticField(cls, Dart_NewString("_fld1")); |
| 979 EXPECT(Dart_IsError(result)); | 1045 EXPECT(Dart_IsError(result)); |
| 980 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld3")); | 1046 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld3")); |
| 981 EXPECT(Dart_IsError(result)); | 1047 EXPECT(Dart_IsError(result)); |
| 982 result = Dart_GetStaticField(cls, Dart_NewString("_fld4")); | 1048 result = Dart_GetStaticField(cls, Dart_NewString("_fld4")); |
| 983 EXPECT_VALID(result); | 1049 EXPECT_VALID(result); |
| 984 int64_t value = 0; | 1050 int64_t value = 0; |
| 985 result = Dart_IntegerValue(result, &value); | 1051 result = Dart_IntegerToInt64(result, &value); |
| 986 EXPECT_EQ(10, value); | 1052 EXPECT_EQ(10, value); |
| 987 result = Dart_SetStaticField(cls, | 1053 result = Dart_SetStaticField(cls, |
| 988 Dart_NewString("_fld4"), | 1054 Dart_NewString("_fld4"), |
| 989 Dart_NewInteger(20)); | 1055 Dart_NewInteger(20)); |
| 990 EXPECT(Dart_IsError(result)); | 1056 EXPECT(Dart_IsError(result)); |
| 991 result = Dart_GetStaticField(cls, Dart_NewString("_fld3")); | 1057 result = Dart_GetStaticField(cls, Dart_NewString("_fld3")); |
| 992 EXPECT_VALID(result); | 1058 EXPECT_VALID(result); |
| 993 result = Dart_SetStaticField(cls, | 1059 result = Dart_SetStaticField(cls, |
| 994 Dart_NewString("_fld3"), | 1060 Dart_NewString("_fld3"), |
| 995 Dart_NewInteger(200)); | 1061 Dart_NewInteger(200)); |
| 996 EXPECT_VALID(result); | 1062 EXPECT_VALID(result); |
| 997 result = Dart_IntegerValue(result, &value); | 1063 result = Dart_IntegerToInt64(result, &value); |
| 998 EXPECT_EQ(200, value); | 1064 EXPECT_EQ(200, value); |
| 999 | 1065 |
| 1000 // Now access and set various instance fields of the returned object. | 1066 // Now access and set various instance fields of the returned object. |
| 1001 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld3")); | 1067 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld3")); |
| 1002 EXPECT(Dart_IsError(result)); | 1068 EXPECT(Dart_IsError(result)); |
| 1003 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld1")); | 1069 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld1")); |
| 1004 EXPECT_VALID(result); | 1070 EXPECT_VALID(result); |
| 1005 result = Dart_IntegerValue(result, &value); | 1071 result = Dart_IntegerToInt64(result, &value); |
| 1006 EXPECT_EQ(10, value); | 1072 EXPECT_EQ(10, value); |
| 1007 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld2")); | 1073 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld2")); |
| 1008 EXPECT_VALID(result); | 1074 EXPECT_VALID(result); |
| 1009 result = Dart_IntegerValue(result, &value); | 1075 result = Dart_IntegerToInt64(result, &value); |
| 1010 EXPECT_EQ(20, value); | 1076 EXPECT_EQ(20, value); |
| 1011 result = Dart_SetInstanceField(retobj, | 1077 result = Dart_SetInstanceField(retobj, |
| 1012 Dart_NewString("_fld2"), | 1078 Dart_NewString("_fld2"), |
| 1013 Dart_NewInteger(40)); | 1079 Dart_NewInteger(40)); |
| 1014 EXPECT(Dart_IsError(result)); | 1080 EXPECT(Dart_IsError(result)); |
| 1015 result = Dart_SetInstanceField(retobj, | 1081 result = Dart_SetInstanceField(retobj, |
| 1016 Dart_NewString("_fld1"), | 1082 Dart_NewString("_fld1"), |
| 1017 Dart_NewInteger(40)); | 1083 Dart_NewInteger(40)); |
| 1018 EXPECT_VALID(result); | 1084 EXPECT_VALID(result); |
| 1019 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld1")); | 1085 result = Dart_GetInstanceField(retobj, Dart_NewString("_fld1")); |
| 1020 EXPECT_VALID(result); | 1086 EXPECT_VALID(result); |
| 1021 result = Dart_IntegerValue(result, &value); | 1087 result = Dart_IntegerToInt64(result, &value); |
| 1022 EXPECT_EQ(40, value); | 1088 EXPECT_EQ(40, value); |
| 1023 } | 1089 } |
| 1024 } | 1090 } |
| 1025 | 1091 |
| 1026 | 1092 |
| 1027 void NativeFieldLookup(Dart_NativeArguments args) { | 1093 void NativeFieldLookup(Dart_NativeArguments args) { |
| 1028 UNREACHABLE(); | 1094 UNREACHABLE(); |
| 1029 } | 1095 } |
| 1030 | 1096 |
| 1031 | 1097 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 static void TestNativeFields(Dart_Handle retobj) { | 1289 static void TestNativeFields(Dart_Handle retobj) { |
| 1224 // Access and set various instance fields of the object. | 1290 // Access and set various instance fields of the object. |
| 1225 Dart_Handle result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); | 1291 Dart_Handle result = Dart_GetInstanceField(retobj, Dart_NewString("fld3")); |
| 1226 EXPECT(Dart_IsError(result)); | 1292 EXPECT(Dart_IsError(result)); |
| 1227 result = Dart_GetInstanceField(retobj, Dart_NewString("fld0")); | 1293 result = Dart_GetInstanceField(retobj, Dart_NewString("fld0")); |
| 1228 EXPECT_VALID(result); | 1294 EXPECT_VALID(result); |
| 1229 EXPECT(Dart_IsNull(result)); | 1295 EXPECT(Dart_IsNull(result)); |
| 1230 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); | 1296 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); |
| 1231 EXPECT_VALID(result); | 1297 EXPECT_VALID(result); |
| 1232 int64_t value = 0; | 1298 int64_t value = 0; |
| 1233 result = Dart_IntegerValue(result, &value); | 1299 result = Dart_IntegerToInt64(result, &value); |
| 1234 EXPECT_EQ(10, value); | 1300 EXPECT_EQ(10, value); |
| 1235 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); | 1301 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); |
| 1236 EXPECT_VALID(result); | 1302 EXPECT_VALID(result); |
| 1237 result = Dart_IntegerValue(result, &value); | 1303 result = Dart_IntegerToInt64(result, &value); |
| 1238 EXPECT_EQ(20, value); | 1304 EXPECT_EQ(20, value); |
| 1239 result = Dart_SetInstanceField(retobj, | 1305 result = Dart_SetInstanceField(retobj, |
| 1240 Dart_NewString("fld2"), | 1306 Dart_NewString("fld2"), |
| 1241 Dart_NewInteger(40)); | 1307 Dart_NewInteger(40)); |
| 1242 EXPECT(Dart_IsError(result)); | 1308 EXPECT(Dart_IsError(result)); |
| 1243 result = Dart_SetInstanceField(retobj, | 1309 result = Dart_SetInstanceField(retobj, |
| 1244 Dart_NewString("fld1"), | 1310 Dart_NewString("fld1"), |
| 1245 Dart_NewInteger(40)); | 1311 Dart_NewInteger(40)); |
| 1246 EXPECT_VALID(result); | 1312 EXPECT_VALID(result); |
| 1247 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); | 1313 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); |
| 1248 EXPECT_VALID(result); | 1314 EXPECT_VALID(result); |
| 1249 result = Dart_IntegerValue(result, &value); | 1315 result = Dart_IntegerToInt64(result, &value); |
| 1250 EXPECT_EQ(40, value); | 1316 EXPECT_EQ(40, value); |
| 1251 | 1317 |
| 1252 // Now access and set various native instance fields of the returned object. | 1318 // Now access and set various native instance fields of the returned object. |
| 1253 const int kNativeFld0 = 0; | 1319 const int kNativeFld0 = 0; |
| 1254 const int kNativeFld1 = 1; | 1320 const int kNativeFld1 = 1; |
| 1255 const int kNativeFld2 = 2; | 1321 const int kNativeFld2 = 2; |
| 1256 const int kNativeFld3 = 3; | 1322 const int kNativeFld3 = 3; |
| 1257 const int kNativeFld4 = 4; | 1323 const int kNativeFld4 = 4; |
| 1258 intptr_t field_value = 0; | 1324 intptr_t field_value = 0; |
| 1259 result = Dart_GetNativeInstanceField(retobj, kNativeFld4, &field_value); | 1325 result = Dart_GetNativeInstanceField(retobj, kNativeFld4, &field_value); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1281 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 4000); | 1347 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 4000); |
| 1282 EXPECT_VALID(result); | 1348 EXPECT_VALID(result); |
| 1283 result = Dart_GetNativeInstanceField(retobj, kNativeFld3, &field_value); | 1349 result = Dart_GetNativeInstanceField(retobj, kNativeFld3, &field_value); |
| 1284 EXPECT_VALID(result); | 1350 EXPECT_VALID(result); |
| 1285 EXPECT_EQ(4000, field_value); | 1351 EXPECT_EQ(4000, field_value); |
| 1286 | 1352 |
| 1287 // Now re-access various dart instance fields of the returned object | 1353 // Now re-access various dart instance fields of the returned object |
| 1288 // to ensure that there was no corruption while setting native fields. | 1354 // to ensure that there was no corruption while setting native fields. |
| 1289 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); | 1355 result = Dart_GetInstanceField(retobj, Dart_NewString("fld1")); |
| 1290 EXPECT_VALID(result); | 1356 EXPECT_VALID(result); |
| 1291 result = Dart_IntegerValue(result, &value); | 1357 result = Dart_IntegerToInt64(result, &value); |
| 1292 EXPECT_EQ(40, value); | 1358 EXPECT_EQ(40, value); |
| 1293 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); | 1359 result = Dart_GetInstanceField(retobj, Dart_NewString("fld2")); |
| 1294 EXPECT_VALID(result); | 1360 EXPECT_VALID(result); |
| 1295 result = Dart_IntegerValue(result, &value); | 1361 result = Dart_IntegerToInt64(result, &value); |
| 1296 EXPECT_EQ(20, value); | 1362 EXPECT_EQ(20, value); |
| 1297 } | 1363 } |
| 1298 | 1364 |
| 1299 | 1365 |
| 1300 UNIT_TEST_CASE(NativeFieldAccess) { | 1366 UNIT_TEST_CASE(NativeFieldAccess) { |
| 1301 const char* kScriptChars = | 1367 const char* kScriptChars = |
| 1302 "class NativeFields extends NativeFieldsWrapper {\n" | 1368 "class NativeFields extends NativeFieldsWrapper {\n" |
| 1303 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" | 1369 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" |
| 1304 " int fld0;\n" | 1370 " int fld0;\n" |
| 1305 " int fld1;\n" | 1371 " int fld1;\n" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 0, | 1554 0, |
| 1489 NULL); | 1555 NULL); |
| 1490 | 1556 |
| 1491 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("TestClass")); | 1557 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("TestClass")); |
| 1492 EXPECT_VALID(cls); | 1558 EXPECT_VALID(cls); |
| 1493 | 1559 |
| 1494 // For uninitialized fields, the getter is returned | 1560 // For uninitialized fields, the getter is returned |
| 1495 result = Dart_GetStaticField(cls, Dart_NewString("fld1")); | 1561 result = Dart_GetStaticField(cls, Dart_NewString("fld1")); |
| 1496 EXPECT_VALID(result); | 1562 EXPECT_VALID(result); |
| 1497 int64_t value = 0; | 1563 int64_t value = 0; |
| 1498 result = Dart_IntegerValue(result, &value); | 1564 result = Dart_IntegerToInt64(result, &value); |
| 1499 EXPECT_EQ(7, value); | 1565 EXPECT_EQ(7, value); |
| 1500 | 1566 |
| 1501 result = Dart_GetStaticField(cls, Dart_NewString("fld2")); | 1567 result = Dart_GetStaticField(cls, Dart_NewString("fld2")); |
| 1502 EXPECT_VALID(result); | 1568 EXPECT_VALID(result); |
| 1503 result = Dart_IntegerValue(result, &value); | 1569 result = Dart_IntegerToInt64(result, &value); |
| 1504 EXPECT_EQ(11, value); | 1570 EXPECT_EQ(11, value); |
| 1505 | 1571 |
| 1506 // Overwrite fld2 | 1572 // Overwrite fld2 |
| 1507 result = Dart_SetStaticField(cls, | 1573 result = Dart_SetStaticField(cls, |
| 1508 Dart_NewString("fld2"), | 1574 Dart_NewString("fld2"), |
| 1509 Dart_NewInteger(13)); | 1575 Dart_NewInteger(13)); |
| 1510 EXPECT_VALID(result); | 1576 EXPECT_VALID(result); |
| 1511 | 1577 |
| 1512 // We now get the new value for fld2, not the initializer | 1578 // We now get the new value for fld2, not the initializer |
| 1513 result = Dart_GetStaticField(cls, Dart_NewString("fld2")); | 1579 result = Dart_GetStaticField(cls, Dart_NewString("fld2")); |
| 1514 EXPECT_VALID(result); | 1580 EXPECT_VALID(result); |
| 1515 result = Dart_IntegerValue(result, &value); | 1581 result = Dart_IntegerToInt64(result, &value); |
| 1516 EXPECT_EQ(13, value); | 1582 EXPECT_EQ(13, value); |
| 1517 } | 1583 } |
| 1518 } | 1584 } |
| 1519 | 1585 |
| 1520 | 1586 |
| 1521 UNIT_TEST_CASE(StaticFieldNotFound) { | 1587 UNIT_TEST_CASE(StaticFieldNotFound) { |
| 1522 const char* kScriptChars = | 1588 const char* kScriptChars = |
| 1523 "class TestClass {\n" | 1589 "class TestClass {\n" |
| 1524 " static void testMain() {\n" | 1590 " static void testMain() {\n" |
| 1525 " }\n" | 1591 " }\n" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 // Now invoke a dynamic method and check the result. | 1659 // Now invoke a dynamic method and check the result. |
| 1594 Dart_Handle dart_arguments[1]; | 1660 Dart_Handle dart_arguments[1]; |
| 1595 dart_arguments[0] = Dart_NewInteger(1); | 1661 dart_arguments[0] = Dart_NewInteger(1); |
| 1596 result = Dart_InvokeDynamic(retobj, | 1662 result = Dart_InvokeDynamic(retobj, |
| 1597 Dart_NewString("method1"), | 1663 Dart_NewString("method1"), |
| 1598 1, | 1664 1, |
| 1599 dart_arguments); | 1665 dart_arguments); |
| 1600 EXPECT_VALID(result); | 1666 EXPECT_VALID(result); |
| 1601 EXPECT(Dart_IsInteger(result)); | 1667 EXPECT(Dart_IsInteger(result)); |
| 1602 int64_t value = 0; | 1668 int64_t value = 0; |
| 1603 result = Dart_IntegerValue(result, &value); | 1669 result = Dart_IntegerToInt64(result, &value); |
| 1604 EXPECT_EQ(41, value); | 1670 EXPECT_EQ(41, value); |
| 1605 | 1671 |
| 1606 result = Dart_InvokeDynamic(retobj, Dart_NewString("method2"), 0, NULL); | 1672 result = Dart_InvokeDynamic(retobj, Dart_NewString("method2"), 0, NULL); |
| 1607 EXPECT(Dart_IsError(result)); | 1673 EXPECT(Dart_IsError(result)); |
| 1608 | 1674 |
| 1609 result = Dart_InvokeDynamic(retobj, Dart_NewString("method1"), 0, NULL); | 1675 result = Dart_InvokeDynamic(retobj, Dart_NewString("method1"), 0, NULL); |
| 1610 EXPECT(Dart_IsError(result)); | 1676 EXPECT(Dart_IsError(result)); |
| 1611 } | 1677 } |
| 1612 } | 1678 } |
| 1613 | 1679 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 EXPECT(Dart_IsClosure(retobj)); | 1723 EXPECT(Dart_IsClosure(retobj)); |
| 1658 EXPECT(!Dart_IsClosure(Dart_NewInteger(101))); | 1724 EXPECT(!Dart_IsClosure(Dart_NewInteger(101))); |
| 1659 | 1725 |
| 1660 // Now invoke the closure and check the result. | 1726 // Now invoke the closure and check the result. |
| 1661 Dart_Handle dart_arguments[1]; | 1727 Dart_Handle dart_arguments[1]; |
| 1662 dart_arguments[0] = Dart_NewInteger(1); | 1728 dart_arguments[0] = Dart_NewInteger(1); |
| 1663 result = Dart_InvokeClosure(retobj, 1, dart_arguments); | 1729 result = Dart_InvokeClosure(retobj, 1, dart_arguments); |
| 1664 EXPECT_VALID(result); | 1730 EXPECT_VALID(result); |
| 1665 EXPECT(Dart_IsInteger(result)); | 1731 EXPECT(Dart_IsInteger(result)); |
| 1666 int64_t value = 0; | 1732 int64_t value = 0; |
| 1667 result = Dart_IntegerValue(result, &value); | 1733 result = Dart_IntegerToInt64(result, &value); |
| 1668 EXPECT_EQ(51, value); | 1734 EXPECT_EQ(51, value); |
| 1669 | 1735 |
| 1670 // Invoke closure with wrong number of args, should result in exception. | 1736 // Invoke closure with wrong number of args, should result in exception. |
| 1671 result = Dart_InvokeClosure(retobj, 0, NULL); | 1737 result = Dart_InvokeClosure(retobj, 0, NULL); |
| 1672 EXPECT(Dart_IsError(result)); | 1738 EXPECT(Dart_IsError(result)); |
| 1673 EXPECT(Dart_ErrorHasException(result)); | 1739 EXPECT(Dart_ErrorHasException(result)); |
| 1674 | 1740 |
| 1675 // Invoke a function which returns a closure. | 1741 // Invoke a function which returns a closure. |
| 1676 retobj = Dart_InvokeStatic(lib, | 1742 retobj = Dart_InvokeStatic(lib, |
| 1677 Dart_NewString("InvokeClosureTest"), | 1743 Dart_NewString("InvokeClosureTest"), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 result = Dart_ThrowException(retobj); | 1818 result = Dart_ThrowException(retobj); |
| 1753 EXPECT(Dart_IsError(result)); | 1819 EXPECT(Dart_IsError(result)); |
| 1754 | 1820 |
| 1755 // Now invoke method2 which invokes a natve method where it is | 1821 // Now invoke method2 which invokes a natve method where it is |
| 1756 // ok to throw an exception, check the result which would indicate | 1822 // ok to throw an exception, check the result which would indicate |
| 1757 // if an exception was thrown or not. | 1823 // if an exception was thrown or not. |
| 1758 result = Dart_InvokeDynamic(retobj, Dart_NewString("method2"), 0, NULL); | 1824 result = Dart_InvokeDynamic(retobj, Dart_NewString("method2"), 0, NULL); |
| 1759 EXPECT_VALID(result); | 1825 EXPECT_VALID(result); |
| 1760 EXPECT(Dart_IsInteger(result)); | 1826 EXPECT(Dart_IsInteger(result)); |
| 1761 int64_t value = 0; | 1827 int64_t value = 0; |
| 1762 result = Dart_IntegerValue(result, &value); | 1828 result = Dart_IntegerToInt64(result, &value); |
| 1763 EXPECT_EQ(5, value); | 1829 EXPECT_EQ(5, value); |
| 1764 | 1830 |
| 1765 Dart_ExitScope(); // Exit the Dart API scope. | 1831 Dart_ExitScope(); // Exit the Dart API scope. |
| 1766 EXPECT_EQ(size, state->ZoneSizeInBytes()); | 1832 EXPECT_EQ(size, state->ZoneSizeInBytes()); |
| 1767 } | 1833 } |
| 1768 } | 1834 } |
| 1769 | 1835 |
| 1770 | 1836 |
| 1771 void NativeArgumentCounter(Dart_NativeArguments args) { | 1837 void NativeArgumentCounter(Dart_NativeArguments args) { |
| 1772 Dart_EnterScope(); | 1838 Dart_EnterScope(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1801 | 1867 |
| 1802 Dart_Handle result = Dart_InvokeStatic(lib, | 1868 Dart_Handle result = Dart_InvokeStatic(lib, |
| 1803 Dart_NewString("Test"), | 1869 Dart_NewString("Test"), |
| 1804 Dart_NewString("testMain"), | 1870 Dart_NewString("testMain"), |
| 1805 0, | 1871 0, |
| 1806 NULL); | 1872 NULL); |
| 1807 EXPECT_VALID(result); | 1873 EXPECT_VALID(result); |
| 1808 EXPECT(Dart_IsInteger(result)); | 1874 EXPECT(Dart_IsInteger(result)); |
| 1809 | 1875 |
| 1810 int64_t value = 0; | 1876 int64_t value = 0; |
| 1811 result = Dart_IntegerValue(result, &value); | 1877 result = Dart_IntegerToInt64(result, &value); |
| 1812 EXPECT_VALID(result); | 1878 EXPECT_VALID(result); |
| 1813 EXPECT_EQ(3, value); | 1879 EXPECT_EQ(3, value); |
| 1814 } | 1880 } |
| 1815 } | 1881 } |
| 1816 | 1882 |
| 1817 | 1883 |
| 1818 UNIT_TEST_CASE(GetClass) { | 1884 UNIT_TEST_CASE(GetClass) { |
| 1819 const char* kScriptChars = | 1885 const char* kScriptChars = |
| 1820 "class DoesExist {" | 1886 "class DoesExist {" |
| 1821 "}"; | 1887 "}"; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2000 EXPECT_VALID(result); | 2066 EXPECT_VALID(result); |
| 2001 | 2067 |
| 2002 result = Dart_InvokeStatic(result, | 2068 result = Dart_InvokeStatic(result, |
| 2003 Dart_NewString(""), | 2069 Dart_NewString(""), |
| 2004 Dart_NewString("main"), | 2070 Dart_NewString("main"), |
| 2005 0, | 2071 0, |
| 2006 NULL); | 2072 NULL); |
| 2007 EXPECT_VALID(result); | 2073 EXPECT_VALID(result); |
| 2008 EXPECT(Dart_IsInteger(result)); | 2074 EXPECT(Dart_IsInteger(result)); |
| 2009 int64_t value = 0; | 2075 int64_t value = 0; |
| 2010 EXPECT_VALID(Dart_IntegerValue(result, &value)); | 2076 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 2011 EXPECT_EQ(12345, value); | 2077 EXPECT_EQ(12345, value); |
| 2012 | 2078 |
| 2013 // Further calls to LoadScript are errors. | 2079 // Further calls to LoadScript are errors. |
| 2014 result = Dart_LoadScript(url, source, library_handler); | 2080 result = Dart_LoadScript(url, source, library_handler); |
| 2015 EXPECT(Dart_IsError(result)); | 2081 EXPECT(Dart_IsError(result)); |
| 2016 EXPECT_STREQ("Dart_LoadScript: " | 2082 EXPECT_STREQ("Dart_LoadScript: " |
| 2017 "A script has already been loaded from 'dart:test-lib'.", | 2083 "A script has already been loaded from 'dart:test-lib'.", |
| 2018 Dart_GetError(result)); | 2084 Dart_GetError(result)); |
| 2019 } | 2085 } |
| 2020 | 2086 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 | 2468 |
| 2403 // Call a function and make sure native resolution works. | 2469 // Call a function and make sure native resolution works. |
| 2404 result = Dart_InvokeStatic(lib, | 2470 result = Dart_InvokeStatic(lib, |
| 2405 Dart_NewString("Test"), | 2471 Dart_NewString("Test"), |
| 2406 Dart_NewString("foo"), | 2472 Dart_NewString("foo"), |
| 2407 0, | 2473 0, |
| 2408 NULL); | 2474 NULL); |
| 2409 EXPECT_VALID(result); | 2475 EXPECT_VALID(result); |
| 2410 EXPECT(Dart_IsInteger(result)); | 2476 EXPECT(Dart_IsInteger(result)); |
| 2411 int64_t value = 0; | 2477 int64_t value = 0; |
| 2412 EXPECT_VALID(Dart_IntegerValue(result, &value)); | 2478 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 2413 EXPECT_EQ(654321, value); | 2479 EXPECT_EQ(654321, value); |
| 2414 | 2480 |
| 2415 // A second call succeeds. | 2481 // A second call succeeds. |
| 2416 result = Dart_SetNativeResolver(lib, &MyNativeResolver2); | 2482 result = Dart_SetNativeResolver(lib, &MyNativeResolver2); |
| 2417 EXPECT_VALID(result); | 2483 EXPECT_VALID(result); |
| 2418 | 2484 |
| 2419 // 'foo' has already been resolved so gets the old value. | 2485 // 'foo' has already been resolved so gets the old value. |
| 2420 result = Dart_InvokeStatic(lib, | 2486 result = Dart_InvokeStatic(lib, |
| 2421 Dart_NewString("Test"), | 2487 Dart_NewString("Test"), |
| 2422 Dart_NewString("foo"), | 2488 Dart_NewString("foo"), |
| 2423 0, | 2489 0, |
| 2424 NULL); | 2490 NULL); |
| 2425 EXPECT_VALID(result); | 2491 EXPECT_VALID(result); |
| 2426 EXPECT(Dart_IsInteger(result)); | 2492 EXPECT(Dart_IsInteger(result)); |
| 2427 value = 0; | 2493 value = 0; |
| 2428 EXPECT_VALID(Dart_IntegerValue(result, &value)); | 2494 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 2429 EXPECT_EQ(654321, value); | 2495 EXPECT_EQ(654321, value); |
| 2430 | 2496 |
| 2431 // 'bar' has not yet been resolved so gets the new value. | 2497 // 'bar' has not yet been resolved so gets the new value. |
| 2432 result = Dart_InvokeStatic(lib, | 2498 result = Dart_InvokeStatic(lib, |
| 2433 Dart_NewString("Test"), | 2499 Dart_NewString("Test"), |
| 2434 Dart_NewString("bar"), | 2500 Dart_NewString("bar"), |
| 2435 0, | 2501 0, |
| 2436 NULL); | 2502 NULL); |
| 2437 EXPECT_VALID(result); | 2503 EXPECT_VALID(result); |
| 2438 EXPECT(Dart_IsInteger(result)); | 2504 EXPECT(Dart_IsInteger(result)); |
| 2439 value = 0; | 2505 value = 0; |
| 2440 EXPECT_VALID(Dart_IntegerValue(result, &value)); | 2506 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 2441 EXPECT_EQ(123456, value); | 2507 EXPECT_EQ(123456, value); |
| 2442 | 2508 |
| 2443 // A NULL resolver is okay, but resolution will fail. | 2509 // A NULL resolver is okay, but resolution will fail. |
| 2444 result = Dart_SetNativeResolver(lib, NULL); | 2510 result = Dart_SetNativeResolver(lib, NULL); |
| 2445 EXPECT_VALID(result); | 2511 EXPECT_VALID(result); |
| 2446 | 2512 |
| 2447 result = Dart_InvokeStatic(lib, | 2513 result = Dart_InvokeStatic(lib, |
| 2448 Dart_NewString("Test"), | 2514 Dart_NewString("Test"), |
| 2449 Dart_NewString("baz"), | 2515 Dart_NewString("baz"), |
| 2450 0, | 2516 0, |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2766 } | 2832 } |
| 2767 | 2833 |
| 2768 | 2834 |
| 2769 UNIT_TEST_CASE(RunLoop_Exception) { | 2835 UNIT_TEST_CASE(RunLoop_Exception) { |
| 2770 RunLoopTest(true); | 2836 RunLoopTest(true); |
| 2771 } | 2837 } |
| 2772 | 2838 |
| 2773 #endif // TARGET_ARCH_IA32. | 2839 #endif // TARGET_ARCH_IA32. |
| 2774 | 2840 |
| 2775 } // namespace dart | 2841 } // namespace dart |
| OLD | NEW |