| 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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1133 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| 1134 EXPECT_VALID(result); | 1134 EXPECT_VALID(result); |
| 1135 Dart_ExitScope(); | 1135 Dart_ExitScope(); |
| 1136 } | 1136 } |
| 1137 Dart_ShutdownIsolate(); | 1137 Dart_ShutdownIsolate(); |
| 1138 free(full_snapshot); | 1138 free(full_snapshot); |
| 1139 free(script_snapshot); | 1139 free(script_snapshot); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 | 1142 |
| 1143 UNIT_TEST_CASE(ScriptSnapshot1) { |
| 1144 const char* kScriptChars = |
| 1145 "class _SimpleNumEnumerable<T extends num> {" |
| 1146 "final Iterable<T> _source;" |
| 1147 "const _SimpleNumEnumerable(this._source) : super();" |
| 1148 "}"; |
| 1149 |
| 1150 Dart_Handle result; |
| 1151 uint8_t* buffer; |
| 1152 intptr_t size; |
| 1153 uint8_t* full_snapshot = NULL; |
| 1154 uint8_t* script_snapshot = NULL; |
| 1155 |
| 1156 { |
| 1157 // Start an Isolate, and create a full snapshot of it. |
| 1158 TestIsolateScope __test_isolate__; |
| 1159 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 1160 |
| 1161 // Write out the script snapshot. |
| 1162 result = Dart_CreateSnapshot(&buffer, &size); |
| 1163 EXPECT_VALID(result); |
| 1164 full_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
| 1165 memmove(full_snapshot, buffer, size); |
| 1166 Dart_ExitScope(); |
| 1167 } |
| 1168 |
| 1169 { |
| 1170 // Create an Isolate using the full snapshot, load a script and create |
| 1171 // a script snapshot of the script. |
| 1172 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); |
| 1173 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 1174 |
| 1175 // Create a test library and Load up a test script in it. |
| 1176 TestCase::LoadTestScript(kScriptChars, NULL); |
| 1177 |
| 1178 // Write out the script snapshot. |
| 1179 result = Dart_CreateScriptSnapshot(&buffer, &size); |
| 1180 EXPECT_VALID(result); |
| 1181 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
| 1182 memmove(script_snapshot, buffer, size); |
| 1183 Dart_ExitScope(); |
| 1184 Dart_ShutdownIsolate(); |
| 1185 } |
| 1186 |
| 1187 { |
| 1188 // Now Create an Isolate using the full snapshot and load the |
| 1189 // script snapshot created above and execute it. |
| 1190 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); |
| 1191 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 1192 |
| 1193 // Load the test library from the snapshot. |
| 1194 EXPECT(script_snapshot != NULL); |
| 1195 result = Dart_LoadScriptFromSnapshot(script_snapshot); |
| 1196 EXPECT_VALID(result); |
| 1197 } |
| 1198 Dart_ShutdownIsolate(); |
| 1199 free(full_snapshot); |
| 1200 free(script_snapshot); |
| 1201 } |
| 1202 |
| 1203 |
| 1143 TEST_CASE(IntArrayMessage) { | 1204 TEST_CASE(IntArrayMessage) { |
| 1144 StackZone zone(Isolate::Current()); | 1205 StackZone zone(Isolate::Current()); |
| 1145 uint8_t* buffer = NULL; | 1206 uint8_t* buffer = NULL; |
| 1146 ApiMessageWriter writer(&buffer, &zone_allocator); | 1207 ApiMessageWriter writer(&buffer, &zone_allocator); |
| 1147 | 1208 |
| 1148 static const int kArrayLength = 2; | 1209 static const int kArrayLength = 2; |
| 1149 intptr_t data[kArrayLength] = {1, 2}; | 1210 intptr_t data[kArrayLength] = {1, 2}; |
| 1150 int len = kArrayLength; | 1211 int len = kArrayLength; |
| 1151 writer.WriteMessage(len, data); | 1212 writer.WriteMessage(len, data); |
| 1152 | 1213 |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 EXPECT(Dart_ErrorHasException(result)); | 2098 EXPECT(Dart_ErrorHasException(result)); |
| 2038 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n", | 2099 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n", |
| 2039 Dart_GetError(result)); | 2100 Dart_GetError(result)); |
| 2040 | 2101 |
| 2041 Dart_ExitScope(); | 2102 Dart_ExitScope(); |
| 2042 } | 2103 } |
| 2043 | 2104 |
| 2044 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2105 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 2045 | 2106 |
| 2046 } // namespace dart | 2107 } // namespace dart |
| OLD | NEW |