| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_debugger_api.h" | 5 #include "include/dart_debugger_api.h" | 
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" | 
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" | 
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" | 
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" | 
| 10 #include "vm/dart_api_message.h" | 10 #include "vm/dart_api_message.h" | 
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1113 | 1113 | 
| 1114     // Create a test library and Load up a test script in it. | 1114     // Create a test library and Load up a test script in it. | 
| 1115     TestCase::LoadTestScript(kScriptChars, NULL); | 1115     TestCase::LoadTestScript(kScriptChars, NULL); | 
| 1116 | 1116 | 
| 1117     EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1117     EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 
| 1118                                            import_lib, | 1118                                            import_lib, | 
| 1119                                            Dart_Null())); | 1119                                            Dart_Null())); | 
| 1120     EXPECT_VALID(Api::CheckIsolateState(Isolate::Current())); | 1120     EXPECT_VALID(Api::CheckIsolateState(Isolate::Current())); | 
| 1121 | 1121 | 
| 1122     // Get list of library URLs loaded and save the count. | 1122     // Get list of library URLs loaded and save the count. | 
| 1123     Dart_Handle libs = Dart_GetLibraryURLs(); | 1123     Dart_Handle libs = Dart_GetLibraryIds(); | 
| 1124     EXPECT(Dart_IsList(libs)); | 1124     EXPECT(Dart_IsList(libs)); | 
| 1125     Dart_ListLength(libs, &expected_num_libs); | 1125     Dart_ListLength(libs, &expected_num_libs); | 
| 1126 | 1126 | 
| 1127     // Write out the script snapshot. | 1127     // Write out the script snapshot. | 
| 1128     result = Dart_CreateScriptSnapshot(&buffer, &size); | 1128     result = Dart_CreateScriptSnapshot(&buffer, &size); | 
| 1129     EXPECT_VALID(result); | 1129     EXPECT_VALID(result); | 
| 1130     script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1130     script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 
| 1131     memmove(script_snapshot, buffer, size); | 1131     memmove(script_snapshot, buffer, size); | 
| 1132     Dart_ExitScope(); | 1132     Dart_ExitScope(); | 
| 1133     Dart_ShutdownIsolate(); | 1133     Dart_ShutdownIsolate(); | 
| 1134   } | 1134   } | 
| 1135 | 1135 | 
| 1136   { | 1136   { | 
| 1137     // Now Create an Isolate using the full snapshot and load the | 1137     // Now Create an Isolate using the full snapshot and load the | 
| 1138     // script snapshot created above and execute it. | 1138     // script snapshot created above and execute it. | 
| 1139     TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 1139     TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 
| 1140     Dart_EnterScope();  // Start a Dart API scope for invoking API functions. | 1140     Dart_EnterScope();  // Start a Dart API scope for invoking API functions. | 
| 1141 | 1141 | 
| 1142     // Load the test library from the snapshot. | 1142     // Load the test library from the snapshot. | 
| 1143     EXPECT(script_snapshot != NULL); | 1143     EXPECT(script_snapshot != NULL); | 
| 1144     result = Dart_LoadScriptFromSnapshot(script_snapshot, size); | 1144     result = Dart_LoadScriptFromSnapshot(script_snapshot, size); | 
| 1145     EXPECT_VALID(result); | 1145     EXPECT_VALID(result); | 
| 1146 | 1146 | 
| 1147     // Get list of library URLs loaded and compare with expected count. | 1147     // Get list of library URLs loaded and compare with expected count. | 
| 1148     Dart_Handle libs = Dart_GetLibraryURLs(); | 1148     Dart_Handle libs = Dart_GetLibraryIds(); | 
| 1149     EXPECT(Dart_IsList(libs)); | 1149     EXPECT(Dart_IsList(libs)); | 
| 1150     Dart_ListLength(libs, &actual_num_libs); | 1150     Dart_ListLength(libs, &actual_num_libs); | 
| 1151 | 1151 | 
| 1152     EXPECT_EQ(expected_num_libs, actual_num_libs); | 1152     EXPECT_EQ(expected_num_libs, actual_num_libs); | 
| 1153 | 1153 | 
| 1154     // Invoke a function which returns an object. | 1154     // Invoke a function which returns an object. | 
| 1155     Dart_Handle cls = Dart_GetClass(result, NewString("FieldsTest")); | 1155     Dart_Handle cls = Dart_GetClass(result, NewString("FieldsTest")); | 
| 1156     result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1156     result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 
| 1157     EXPECT_VALID(result); | 1157     EXPECT_VALID(result); | 
| 1158     Dart_ExitScope(); | 1158     Dart_ExitScope(); | 
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2210   EXPECT(Dart_ErrorHasException(result)); | 2210   EXPECT(Dart_ErrorHasException(result)); | 
| 2211   EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2211   EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 
| 2212                    Dart_GetError(result)); | 2212                    Dart_GetError(result)); | 
| 2213 | 2213 | 
| 2214   Dart_ExitScope(); | 2214   Dart_ExitScope(); | 
| 2215 } | 2215 } | 
| 2216 | 2216 | 
| 2217 #endif  // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2217 #endif  // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 
| 2218 | 2218 | 
| 2219 }  // namespace dart | 2219 }  // namespace dart | 
| OLD | NEW | 
|---|