Index: vm/dart_api_impl_test.cc |
=================================================================== |
--- vm/dart_api_impl_test.cc (revision 1955) |
+++ vm/dart_api_impl_test.cc (working copy) |
@@ -13,7 +13,6 @@ |
namespace dart { |
- |
#if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. |
UNIT_TEST_CASE(ErrorHandles) { |
@@ -24,8 +23,8 @@ |
" }\n" |
"}\n"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
+ |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
Dart_Handle instance = Dart_True(); |
@@ -59,30 +58,22 @@ |
EXPECT(Dart_IsError(Dart_ErrorGetStacktrace(instance))); |
EXPECT(Dart_IsError(Dart_ErrorGetStacktrace(error))); |
EXPECT_VALID(Dart_ErrorGetStacktrace(exception)); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
#endif |
UNIT_TEST_CASE(Dart_Error) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle error = Dart_Error("An %s", "error"); |
EXPECT(Dart_IsError(error)); |
EXPECT_STREQ("An error", Dart_GetError(error)); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
UNIT_TEST_CASE(Null) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
Dart_Handle null = Dart_Null(); |
EXPECT_VALID(null); |
@@ -91,15 +82,11 @@ |
Dart_Handle str = Dart_NewString("test"); |
EXPECT_VALID(str); |
EXPECT(!Dart_IsNull(str)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
UNIT_TEST_CASE(IsSame) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
bool same = false; |
Dart_Handle five = Dart_NewString("5"); |
@@ -132,17 +119,13 @@ |
EXPECT_VALID(Dart_IsSame(class1, class2, &same)); |
EXPECT(!same); |
} |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
#if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. |
UNIT_TEST_CASE(ObjectEquals) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
bool equal = false; |
Dart_Handle five = Dart_NewString("5"); |
@@ -160,16 +143,12 @@ |
// Different objects. |
EXPECT_VALID(Dart_ObjectEquals(five, seven, &equal)); |
EXPECT(!equal); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
#endif |
UNIT_TEST_CASE(BooleanValues) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
Dart_Handle str = Dart_NewString("test"); |
EXPECT(!Dart_IsBoolean(str)); |
@@ -191,15 +170,11 @@ |
result = Dart_BooleanValue(val2, &value); |
EXPECT_VALID(result); |
EXPECT(!value); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
UNIT_TEST_CASE(BooleanConstants) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
Dart_Handle true_handle = Dart_True(); |
EXPECT_VALID(true_handle); |
@@ -217,15 +192,11 @@ |
result = Dart_BooleanValue(false_handle, &value); |
EXPECT_VALID(result); |
EXPECT(!value); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
UNIT_TEST_CASE(DoubleValues) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
const double kDoubleVal1 = 201.29; |
const double kDoubleVal2 = 101.19; |
@@ -240,9 +211,6 @@ |
result = Dart_DoubleValue(val2, &out2); |
EXPECT_VALID(result); |
EXPECT_EQ(kDoubleVal2, out2); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
@@ -259,10 +227,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -302,18 +268,14 @@ |
NULL); |
EXPECT_VALID(result); |
EXPECT(!Dart_IsNumber(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
#endif |
UNIT_TEST_CASE(IntegerValues) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
const int64_t kIntegerVal1 = 100; |
const int64_t kIntegerVal2 = 0xffffffff; |
@@ -351,15 +313,11 @@ |
result = Dart_IntegerValueHexCString(val3, &chars); |
EXPECT_VALID(result); |
EXPECT(!strcmp(kIntegerVal3, chars)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
UNIT_TEST_CASE(ArrayValues) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
const int kArrayLength = 10; |
Dart_Handle str = Dart_NewString("test"); |
@@ -393,15 +351,11 @@ |
EXPECT_VALID(result); |
EXPECT_EQ(i, value); |
} |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
UNIT_TEST_CASE(IsString) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
uint8_t data8[] = { 'o', 'n', 'e', 0xFF }; |
@@ -447,9 +401,6 @@ |
EXPECT(Dart_IsString(ext32)); |
EXPECT(!Dart_IsString8(ext32)); |
EXPECT(!Dart_IsString16(ext32)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
@@ -469,10 +420,8 @@ |
"}"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -574,10 +523,7 @@ |
// Check if we get an exception when accessing beyond limit. |
result = Dart_ListGetAt(ListAccessTestObj, 4); |
EXPECT(Dart_IsError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
#endif // TARGET_ARCH_IA32. |
@@ -586,7 +532,8 @@ |
// Unit test for entering a scope, creating a local handle and exiting |
// the scope. |
UNIT_TEST_CASE(EnterExitScope) { |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
+ |
Isolate* isolate = Isolate::Current(); |
EXPECT(isolate != NULL); |
ApiState* state = isolate->api_state(); |
@@ -604,7 +551,6 @@ |
} |
Dart_ExitScope(); |
EXPECT(scope == state->top_scope()); |
- Dart_ShutdownIsolate(); |
} |
@@ -612,7 +558,7 @@ |
UNIT_TEST_CASE(PersistentHandles) { |
const char* kTestString1 = "Test String1"; |
const char* kTestString2 = "Test String2"; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestCase::CreateTestIsolate(); |
Isolate* isolate = Isolate::Current(); |
EXPECT(isolate != NULL); |
ApiState* state = isolate->api_state(); |
@@ -678,7 +624,7 @@ |
// Test that we are able to create a persistent handle from a |
// persistent handle. |
UNIT_TEST_CASE(NewPersistentHandle_FromPersistentHandle) { |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
Isolate* isolate = Isolate::Current(); |
EXPECT(isolate != NULL); |
@@ -699,8 +645,6 @@ |
Dart_Handle result = Dart_BooleanValue(obj2, &value); |
EXPECT_VALID(result); |
EXPECT(value); |
- |
- Dart_ShutdownIsolate(); |
} |
@@ -708,7 +652,7 @@ |
// Ensure that the local handles get all cleaned out when exiting the |
// scope. |
UNIT_TEST_CASE(LocalHandles) { |
- Dart_CreateIsolate(NULL, NULL); |
+ TestCase::CreateTestIsolate(); |
Isolate* isolate = Isolate::Current(); |
EXPECT(isolate != NULL); |
ApiState* state = isolate->api_state(); |
@@ -775,7 +719,7 @@ |
// zone for the scope. Ensure that the memory is freed when the scope |
// exits. |
UNIT_TEST_CASE(LocalZoneMemory) { |
- Dart_CreateIsolate(NULL, NULL); |
+ TestCase::CreateTestIsolate(); |
Isolate* isolate = Isolate::Current(); |
EXPECT(isolate != NULL); |
ApiState* state = isolate->api_state(); |
@@ -821,14 +765,14 @@ |
UNIT_TEST_CASE(Isolates) { |
// This test currently assumes that the Dart_Isolate type is an opaque |
// representation of Isolate*. |
- Dart_Isolate iso_1 = Dart_CreateIsolate(NULL, NULL); |
+ Dart_Isolate iso_1 = TestCase::CreateTestIsolate(); |
EXPECT_EQ(iso_1, Isolate::Current()); |
Dart_Isolate isolate = Dart_CurrentIsolate(); |
EXPECT_EQ(iso_1, isolate); |
Dart_ExitIsolate(); |
EXPECT(NULL == Isolate::Current()); |
EXPECT(NULL == Dart_CurrentIsolate()); |
- Dart_Isolate iso_2 = Dart_CreateIsolate(NULL, NULL); |
+ Dart_Isolate iso_2 = TestCase::CreateTestIsolate(); |
EXPECT_EQ(iso_2, Isolate::Current()); |
Dart_ExitIsolate(); |
EXPECT(NULL == Isolate::Current()); |
@@ -857,7 +801,7 @@ |
UNIT_TEST_CASE(SetMessageCallbacks) { |
- Dart_Isolate dart_isolate = Dart_CreateIsolate(NULL, NULL); |
+ Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); |
Dart_SetMessageCallbacks(&MyPostMessageCallback, &MyClosePortCallback); |
Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
EXPECT_EQ(&MyPostMessageCallback, isolate->post_message_callback()); |
@@ -885,10 +829,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -948,10 +890,7 @@ |
EXPECT_VALID(result); |
result = Dart_IntegerValue(result, &value); |
EXPECT_EQ(40, value); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -972,10 +911,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Load up a test script which extends the native wrapper class. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1035,10 +972,7 @@ |
EXPECT_VALID(result); |
result = Dart_IntegerValue(result, &value); |
EXPECT_EQ(40, value); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1070,9 +1004,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
const int kNumNativeFields = 4; |
// Create a test library. |
@@ -1107,10 +1040,7 @@ |
EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, |
kObjectAlignment), |
cls.instance_size()); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1131,10 +1061,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1148,10 +1076,7 @@ |
// "NativeFieldsWrapper" and there is no definition of it either |
// in the dart code or through the native field injection mechanism. |
EXPECT(Dart_IsError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1173,9 +1098,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
const int kNumNativeFields = 2; |
// Load up a test script in the test library. |
@@ -1202,10 +1126,7 @@ |
EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, |
kObjectAlignment), |
cls.instance_size()); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1227,10 +1148,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Load up a test script in the test library. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1247,9 +1166,7 @@ |
"native fields class, but library '%s' has no native resolvers", |
TestCase::url()); |
EXPECT_STREQ(Dart_GetError(expected_error), Dart_GetError(result)); |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1341,9 +1258,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
const int kNumNativeFields = 4; |
// Create a test library. |
@@ -1368,10 +1284,7 @@ |
// Now access and set various instance fields of the returned object. |
TestNativeFields(retobj); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1391,10 +1304,8 @@ |
" return obj;\n" |
" }\n" |
"}\n"; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Load up a test script in the test library. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, |
native_field_lookup); |
@@ -1409,10 +1320,7 @@ |
// Now access and set various instance fields of the returned object. |
TestNativeFields(retobj); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1436,10 +1344,9 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
DARTSCOPE(Isolate::Current()); |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1497,10 +1404,7 @@ |
EXPECT(Dart_IsError(result)); |
result = Dart_SetNativeInstanceField(retobj, kNativeFld0, 400); |
EXPECT(Dart_IsError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1514,10 +1418,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1554,10 +1456,7 @@ |
EXPECT_VALID(result); |
result = Dart_IntegerValue(result, &value); |
EXPECT_EQ(13, value); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1569,10 +1468,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1597,10 +1494,7 @@ |
EXPECT(Dart_IsError(result)); |
EXPECT_STREQ("Specified field is not found in the class", |
Dart_GetError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1622,10 +1516,9 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
DARTSCOPE(Isolate::Current()); |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1657,10 +1550,7 @@ |
result = Dart_InvokeDynamic(retobj, Dart_NewString("method1"), 0, NULL); |
EXPECT(Dart_IsError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1691,10 +1581,9 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
DARTSCOPE(Isolate::Current()); |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1741,10 +1630,7 @@ |
result = Dart_InvokeClosure(retobj, 1, dart_arguments); |
EXPECT(Dart_IsError(result)); |
EXPECT(Dart_ErrorHasException(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1781,7 +1667,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
+ |
Isolate* isolate = Isolate::Current(); |
EXPECT(isolate != NULL); |
ApiState* state = isolate->api_state(); |
@@ -1820,7 +1707,6 @@ |
Dart_ExitScope(); // Exit the Dart API scope. |
EXPECT_EQ(size, state->ZoneSizeInBytes()); |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1849,9 +1735,8 @@ |
" }" |
"}"; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); |
Dart_Handle lib = TestCase::LoadTestScript( |
kScriptChars, |
reinterpret_cast<Dart_NativeEntryResolver>(gnac_lookup)); |
@@ -1868,10 +1753,7 @@ |
result = Dart_IntegerValue(result, &value); |
EXPECT_VALID(result); |
EXPECT_EQ(3, value); |
- |
- Dart_ExitScope(); |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -1880,8 +1762,8 @@ |
"class DoesExist {" |
"}"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
+ |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
// Lookup a class that does exist. |
@@ -1893,9 +1775,6 @@ |
EXPECT(Dart_IsError(cls)); |
EXPECT_STREQ("Class 'DoesNotExist' not found in library 'dart:test-lib'.", |
Dart_GetError(cls)); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -1912,10 +1791,8 @@ |
"}\n"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
@@ -1976,16 +1853,12 @@ |
// Check that error is returned if null is passed as a class argument. |
result = Dart_ObjectIsType(null, null, &is_instance); |
EXPECT(Dart_IsError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
UNIT_TEST_CASE(NullReceiver) { |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); // Enter a Dart API scope for the unit test. |
+ TestIsolateScope __test_isolate__; |
{ |
DARTSCOPE(Isolate::Current()); |
@@ -2009,8 +1882,6 @@ |
EXPECT(Dart_IsError(result)); |
EXPECT(Dart_ErrorHasException(result)); */ |
} |
- Dart_ExitScope(); // Exit the Dart API scope. |
- Dart_ShutdownIsolate(); |
} |
@@ -2030,8 +1901,7 @@ |
" return 12345;" |
"}"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
@@ -2088,9 +1958,6 @@ |
EXPECT_STREQ("Dart_LoadScript: " |
"A script has already been loaded from 'dart:test-lib'.", |
Dart_GetError(result)); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2098,17 +1965,13 @@ |
const char* kScriptChars = |
")"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
Dart_Handle result = Dart_LoadScript(url, source, library_handler); |
EXPECT(Dart_IsError(result)); |
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2120,8 +1983,7 @@ |
"#library('library1.dart');" |
"#import('library2.dart');"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
// Create a test library and Load up a test script in it. |
Dart_Handle url = Dart_NewString(TestCase::url()); |
@@ -2157,9 +2019,6 @@ |
EXPECT(Dart_IsError(result)); |
EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", |
Dart_GetError(result)); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2167,8 +2026,7 @@ |
const char* kLibrary1Chars = |
"#library('library1_name');"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle url = Dart_NewString("library1_url"); |
Dart_Handle source = Dart_NewString(kLibrary1Chars); |
@@ -2197,9 +2055,6 @@ |
const char* cstr = NULL; |
EXPECT_VALID(Dart_StringToCString(result, &cstr)); |
EXPECT_STREQ("library1_url", cstr); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2209,8 +2064,7 @@ |
const char* kLibrary2Chars = |
"#library('library2_name');"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle error = Dart_Error("incoming error"); |
Dart_Handle result; |
@@ -2259,9 +2113,6 @@ |
result = Dart_LibraryImportLibrary(lib1, lib2); |
EXPECT_VALID(result); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2270,8 +2121,7 @@ |
const char* kLibrary1Chars = |
"#library('library1_name');"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle error = Dart_Error("incoming error"); |
Dart_Handle result; |
@@ -2319,9 +2169,6 @@ |
EXPECT_STREQ( |
"Dart_LoadLibrary: library 'library1_url' has already been loaded.", |
Dart_GetError(result)); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2330,17 +2177,13 @@ |
"#library('library1_name');" |
")"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle url = Dart_NewString("library1_url"); |
Dart_Handle source = Dart_NewString(kLibrary1Chars); |
Dart_Handle result = Dart_LoadLibrary(url, source); |
EXPECT(Dart_IsError(result)); |
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2352,8 +2195,7 @@ |
const char* kBadSourceChars = |
")"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle error = Dart_Error("incoming error"); |
Dart_Handle result; |
@@ -2432,9 +2274,6 @@ |
source = Dart_NewString(kBadSourceChars); |
result = Dart_LoadSource(lib, url, source); |
EXPECT(Dart_IsError(result)); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2472,8 +2311,7 @@ |
" static baz() native \"SomeNativeFunction3\";" |
"}"; |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ TestIsolateScope __test_isolate__; |
Dart_Handle error = Dart_Error("incoming error"); |
Dart_Handle result; |
@@ -2556,9 +2394,6 @@ |
EXPECT(Dart_IsError(result)); |
EXPECT(strstr(Dart_GetError(result), |
"native function 'SomeNativeFunction3' cannot be found")); |
- |
- Dart_ExitScope(); |
- Dart_ShutdownIsolate(); |
} |
@@ -2577,10 +2412,8 @@ |
"var foo;"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
@@ -2603,10 +2436,7 @@ |
EXPECT_STREQ("Duplicate definition : 'foo' is defined in" |
" 'library2.dart' and 'dart:test-lib'\n", |
Dart_GetError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -2625,10 +2455,8 @@ |
"var foo;"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
@@ -2648,10 +2476,7 @@ |
0, |
NULL); |
EXPECT_VALID(result); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -2669,10 +2494,8 @@ |
"var foo;"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
@@ -2695,10 +2518,7 @@ |
EXPECT_STREQ("Duplicate definition : 'foo' is defined in" |
" 'library1.dart' and 'library2.dart'\n", |
Dart_GetError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -2735,10 +2555,8 @@ |
"var fooC;"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
@@ -2777,10 +2595,7 @@ |
EXPECT_STREQ("Duplicate definition : 'fooC' is defined in" |
" 'libraryF.dart' and 'libraryC.dart'\n", |
Dart_GetError(result)); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
@@ -2798,10 +2613,8 @@ |
"}"; |
Dart_Handle result; |
- Dart_CreateIsolate(NULL, NULL); |
+ TestIsolateScope __test_isolate__; |
{ |
- Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
- |
// Create a test library and Load up a test script in it. |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
@@ -2817,14 +2630,11 @@ |
0, |
NULL); |
EXPECT_VALID(result); |
- |
- Dart_ExitScope(); // Exit the Dart API scope. |
} |
- Dart_ShutdownIsolate(); |
} |
-static void* RunLoopTest_InitCallback(void* data) { |
+static bool RunLoopTestCallback(void* data, char** error) { |
const char* kScriptChars = |
"#import('builtin');\n" |
"class MyIsolate extends Isolate {\n" |
@@ -2849,25 +2659,28 @@ |
" });\n" |
"}\n"; |
+ Dart_Isolate isolate = TestCase::CreateTestIsolate(); |
+ ASSERT(isolate != NULL); |
Dart_EnterScope(); |
Dart_Handle url = Dart_NewString(TestCase::url()); |
Dart_Handle source = Dart_NewString(kScriptChars); |
- Dart_Handle lib = Dart_LoadScript(url, source, library_handler); |
+ Dart_Handle lib = Dart_LoadScript(url, source, TestCase::library_handler); |
EXPECT_VALID(lib); |
Dart_ExitScope(); |
- return NULL; |
+ return true; |
} |
// Common code for RunLoop_Success/RunLoop_Failure. |
static void RunLoopTest(bool throw_exception) { |
- Dart_IsolateInitCallback saved = Isolate::InitCallback(); |
- Isolate::SetInitCallback(RunLoopTest_InitCallback); |
- Dart_CreateIsolate(NULL, NULL); |
- Dart_EnterScope(); |
+ Dart_IsolateCreateCallback saved = Isolate::CreateCallback(); |
+ Isolate::SetCreateCallback(RunLoopTestCallback); |
+ RunLoopTestCallback(NULL, NULL); |
+ Dart_EnterScope(); |
Dart_Handle lib = Dart_LookupLibrary(Dart_NewString(TestCase::url())); |
EXPECT_VALID(lib); |
+ |
Dart_Handle result; |
Dart_Handle args[1]; |
args[0] = (throw_exception ? Dart_True() : Dart_False()); |
@@ -2883,7 +2696,7 @@ |
Dart_ExitScope(); |
Dart_ShutdownIsolate(); |
- Isolate::SetInitCallback(saved); |
+ Isolate::SetCreateCallback(saved); |
} |