| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 result = Dart_IntegerValue(result, &value); | 392 result = Dart_IntegerValue(result, &value); |
| 393 EXPECT_VALID(result); | 393 EXPECT_VALID(result); |
| 394 EXPECT_EQ(i, value); | 394 EXPECT_EQ(i, value); |
| 395 } | 395 } |
| 396 | 396 |
| 397 Dart_ExitScope(); // Exit the Dart API scope. | 397 Dart_ExitScope(); // Exit the Dart API scope. |
| 398 Dart_ShutdownIsolate(); | 398 Dart_ShutdownIsolate(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 | 401 |
| 402 UNIT_TEST_CASE(IsString) { |
| 403 Dart_CreateIsolate(NULL, NULL); |
| 404 Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
| 405 |
| 406 uint8_t data8[] = { 'o', 'n', 'e', 0xFF }; |
| 407 |
| 408 Dart_Handle str8 = Dart_NewString8(data8, ARRAY_SIZE(data8)); |
| 409 EXPECT_VALID(str8); |
| 410 EXPECT(Dart_IsString(str8)); |
| 411 EXPECT(Dart_IsString8(str8)); |
| 412 EXPECT(Dart_IsString16(str8)); |
| 413 |
| 414 Dart_Handle ext8 = Dart_NewExternalString8(data8, ARRAY_SIZE(data8), |
| 415 NULL, NULL); |
| 416 EXPECT_VALID(ext8); |
| 417 EXPECT(Dart_IsString(ext8)); |
| 418 EXPECT(Dart_IsString8(ext8)); |
| 419 EXPECT(Dart_IsString16(ext8)); |
| 420 |
| 421 uint16_t data16[] = { 't', 'w', 'o', 0xFFFF }; |
| 422 |
| 423 Dart_Handle str16 = Dart_NewString16(data16, ARRAY_SIZE(data16)); |
| 424 EXPECT_VALID(str16); |
| 425 EXPECT(Dart_IsString(str16)); |
| 426 EXPECT(!Dart_IsString8(str16)); |
| 427 EXPECT(Dart_IsString16(str16)); |
| 428 |
| 429 Dart_Handle ext16 = Dart_NewExternalString16(data16, ARRAY_SIZE(data16), |
| 430 NULL, NULL); |
| 431 EXPECT_VALID(ext16); |
| 432 EXPECT(Dart_IsString(ext16)); |
| 433 EXPECT(!Dart_IsString8(ext16)); |
| 434 EXPECT(Dart_IsString16(ext16)); |
| 435 |
| 436 uint32_t data32[] = { 'f', 'o', 'u', 'r', 0x10FFFF }; |
| 437 |
| 438 Dart_Handle str32 = Dart_NewString32(data32, ARRAY_SIZE(data32)); |
| 439 EXPECT_VALID(str32); |
| 440 EXPECT(Dart_IsString(str32)); |
| 441 EXPECT(!Dart_IsString8(str32)); |
| 442 EXPECT(!Dart_IsString16(str32)); |
| 443 |
| 444 Dart_Handle ext32 = Dart_NewExternalString32(data32, ARRAY_SIZE(data32), |
| 445 NULL, NULL); |
| 446 EXPECT_VALID(ext32); |
| 447 EXPECT(Dart_IsString(ext32)); |
| 448 EXPECT(!Dart_IsString8(ext32)); |
| 449 EXPECT(!Dart_IsString16(ext32)); |
| 450 |
| 451 Dart_ExitScope(); // Exit the Dart API scope. |
| 452 Dart_ShutdownIsolate(); |
| 453 } |
| 454 |
| 455 |
| 402 #if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. | 456 #if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. |
| 403 | 457 |
| 404 UNIT_TEST_CASE(ListAccess) { | 458 UNIT_TEST_CASE(ListAccess) { |
| 405 const char* kScriptChars = | 459 const char* kScriptChars = |
| 406 "class ListAccessTest {" | 460 "class ListAccessTest {" |
| 407 " ListAccessTest() {}" | 461 " ListAccessTest() {}" |
| 408 " static List testMain() {" | 462 " static List testMain() {" |
| 409 " List a = new List();" | 463 " List a = new List();" |
| 410 " a.add(10);" | 464 " a.add(10);" |
| 411 " a.add(20);" | 465 " a.add(20);" |
| (...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 NULL); | 2332 NULL); |
| 2279 EXPECT_VALID(result); | 2333 EXPECT_VALID(result); |
| 2280 | 2334 |
| 2281 Dart_ExitScope(); // Exit the Dart API scope. | 2335 Dart_ExitScope(); // Exit the Dart API scope. |
| 2282 } | 2336 } |
| 2283 Dart_ShutdownIsolate(); | 2337 Dart_ShutdownIsolate(); |
| 2284 } | 2338 } |
| 2285 #endif // TARGET_ARCH_IA32. | 2339 #endif // TARGET_ARCH_IA32. |
| 2286 | 2340 |
| 2287 } // namespace dart | 2341 } // namespace dart |
| OLD | NEW |