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 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2082 element->value.as_bigint); | 2082 element->value.as_bigint); |
2083 } | 2083 } |
2084 } | 2084 } |
2085 { | 2085 { |
2086 // Generate a list of doubles from Dart code. | 2086 // Generate a list of doubles from Dart code. |
2087 ApiNativeScope scope; | 2087 ApiNativeScope scope; |
2088 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList"); | 2088 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList"); |
2089 EXPECT_NOTNULL(root); | 2089 EXPECT_NOTNULL(root); |
2090 EXPECT_EQ(Dart_CObject_kArray, root->type); | 2090 EXPECT_EQ(Dart_CObject_kArray, root->type); |
2091 EXPECT_EQ(kArrayLength, root->value.as_array.length); | 2091 EXPECT_EQ(kArrayLength, root->value.as_array.length); |
2092 for (int i = 0; i < kArrayLength; i++) { | 2092 Dart_CObject* element = root->value.as_array.values[0]; |
2093 Dart_CObject* element = root->value.as_array.values[i]; | 2093 EXPECT_EQ(Dart_CObject_kDouble, element->type); |
2094 EXPECT_EQ(root->value.as_array.values[0], element); | 2094 EXPECT_EQ(3.14, element->value.as_double); |
siva
2014/04/03 00:23:16
Maybe add a comment here to explain why the hoisti
| |
2095 for (int i = 1; i < kArrayLength; i++) { | |
2096 element = root->value.as_array.values[i]; | |
2097 // Double values are expected to not be canonicalized in messages. | |
2098 EXPECT_NE(root->value.as_array.values[0], element); | |
2095 EXPECT_EQ(Dart_CObject_kDouble, element->type); | 2099 EXPECT_EQ(Dart_CObject_kDouble, element->type); |
2096 EXPECT_EQ(3.14, element->value.as_double); | 2100 EXPECT_EQ(3.14, element->value.as_double); |
2097 } | 2101 } |
2098 } | 2102 } |
2099 { | 2103 { |
2100 // Generate a list of Uint8Lists from Dart code. | 2104 // Generate a list of Uint8Lists from Dart code. |
2101 ApiNativeScope scope; | 2105 ApiNativeScope scope; |
2102 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList"); | 2106 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList"); |
2103 EXPECT_NOTNULL(root); | 2107 EXPECT_NOTNULL(root); |
2104 EXPECT_EQ(Dart_CObject_kArray, root->type); | 2108 EXPECT_EQ(Dart_CObject_kArray, root->type); |
(...skipping 24 matching lines...) Expand all Loading... | |
2129 EXPECT_EQ(0, element->value.as_typed_data.values[1]); | 2133 EXPECT_EQ(0, element->value.as_typed_data.values[1]); |
2130 } | 2134 } |
2131 } | 2135 } |
2132 { | 2136 { |
2133 // Generate a list of objects of different types from Dart code. | 2137 // Generate a list of objects of different types from Dart code. |
2134 ApiNativeScope scope; | 2138 ApiNativeScope scope; |
2135 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList"); | 2139 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList"); |
2136 EXPECT_NOTNULL(root); | 2140 EXPECT_NOTNULL(root); |
2137 EXPECT_EQ(Dart_CObject_kArray, root->type); | 2141 EXPECT_EQ(Dart_CObject_kArray, root->type); |
2138 EXPECT_EQ(kArrayLength, root->value.as_array.length); | 2142 EXPECT_EQ(kArrayLength, root->value.as_array.length); |
2139 for (int i = 0; i < kArrayLength; i++) { | 2143 Dart_CObject* element = root->value.as_array.values[0]; |
2140 Dart_CObject* element = root->value.as_array.values[i]; | 2144 EXPECT_EQ(Dart_CObject_kString, element->type); |
2145 EXPECT_STREQ("A", element->value.as_string); | |
2146 element = root->value.as_array.values[1]; | |
2147 EXPECT_EQ(Dart_CObject_kDouble, element->type); | |
2148 EXPECT_STREQ(2.72, element->value.as_double); | |
2149 for (int i = 2; i < kArrayLength; i++) { | |
2150 element = root->value.as_array.values[i]; | |
2141 if ((i % 2) == 0) { | 2151 if ((i % 2) == 0) { |
2142 EXPECT_EQ(root->value.as_array.values[0], element); | 2152 EXPECT_EQ(root->value.as_array.values[0], element); |
2143 EXPECT_EQ(Dart_CObject_kString, element->type); | 2153 EXPECT_EQ(Dart_CObject_kString, element->type); |
2144 EXPECT_STREQ("A", element->value.as_string); | 2154 EXPECT_STREQ("A", element->value.as_string); |
2145 } else { | 2155 } else { |
2146 EXPECT_EQ(root->value.as_array.values[1], element); | 2156 // Double values are expected to not be canonicalized in messages. |
2157 EXPECT_NE(root->value.as_array.values[1], element); | |
2147 EXPECT_EQ(Dart_CObject_kDouble, element->type); | 2158 EXPECT_EQ(Dart_CObject_kDouble, element->type); |
2148 EXPECT_STREQ(2.72, element->value.as_double); | 2159 EXPECT_STREQ(2.72, element->value.as_double); |
2149 } | 2160 } |
2150 } | 2161 } |
2151 } | 2162 } |
2152 { | 2163 { |
2153 // Generate a list of objects of different types from Dart code. | 2164 // Generate a list of objects of different types from Dart code. |
2154 ApiNativeScope scope; | 2165 ApiNativeScope scope; |
2155 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList"); | 2166 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList"); |
2156 EXPECT_NOTNULL(root); | 2167 EXPECT_NOTNULL(root); |
(...skipping 29 matching lines...) Expand all Loading... | |
2186 "}\n" | 2197 "}\n" |
2187 "getBigintList() {\n" | 2198 "getBigintList() {\n" |
2188 " var bigint = 0x1234567890123456789012345678901234567890;\n" | 2199 " var bigint = 0x1234567890123456789012345678901234567890;\n" |
2189 " var list = [bigint, bigint, bigint, bigint, bigint,\n" | 2200 " var list = [bigint, bigint, bigint, bigint, bigint,\n" |
2190 " bigint, bigint, bigint, bigint, bigint];\n" | 2201 " bigint, bigint, bigint, bigint, bigint];\n" |
2191 " return list;\n" | 2202 " return list;\n" |
2192 "}\n" | 2203 "}\n" |
2193 "getDoubleList() {\n" | 2204 "getDoubleList() {\n" |
2194 " var d = 3.14;\n" | 2205 " var d = 3.14;\n" |
2195 " var list = [3.14, 3.14, 3.14, 3.14, 3.14, 3.14];\n" | 2206 " var list = [3.14, 3.14, 3.14, 3.14, 3.14, 3.14];\n" |
2196 " list.add(3.14);;\n" | 2207 " list.add(3.14);\n" |
2197 " list.add(3.14);;\n" | 2208 " list.add(3.14);\n" |
2198 " list.add(3.14);;\n" | 2209 " list.add(3.14);\n" |
2199 " list.add(3.14);;\n" | 2210 " list.add(3.14);\n" |
2200 " return list;\n" | 2211 " return list;\n" |
2201 "}\n" | 2212 "}\n" |
2202 "getTypedDataList() {\n" | 2213 "getTypedDataList() {\n" |
2203 " var byte_array = new Uint8List(256);\n" | 2214 " var byte_array = new Uint8List(256);\n" |
2204 " var list = [];\n" | 2215 " var list = [];\n" |
2205 " for (var i = 0; i < kArrayLength; i++) {\n" | 2216 " for (var i = 0; i < kArrayLength; i++) {\n" |
2206 " list.add(byte_array);\n" | 2217 " list.add(byte_array);\n" |
2207 " }\n" | 2218 " }\n" |
2208 " return list;\n" | 2219 " return list;\n" |
2209 "}\n" | 2220 "}\n" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2286 element->value.as_bigint); | 2297 element->value.as_bigint); |
2287 } | 2298 } |
2288 } | 2299 } |
2289 { | 2300 { |
2290 // Generate a list of doubles from Dart code. | 2301 // Generate a list of doubles from Dart code. |
2291 ApiNativeScope scope; | 2302 ApiNativeScope scope; |
2292 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList"); | 2303 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList"); |
2293 EXPECT_NOTNULL(root); | 2304 EXPECT_NOTNULL(root); |
2294 EXPECT_EQ(Dart_CObject_kArray, root->type); | 2305 EXPECT_EQ(Dart_CObject_kArray, root->type); |
2295 EXPECT_EQ(kArrayLength, root->value.as_array.length); | 2306 EXPECT_EQ(kArrayLength, root->value.as_array.length); |
2296 for (int i = 0; i < kArrayLength; i++) { | 2307 Dart_CObject* element = root->value.as_array.values[0]; |
2297 Dart_CObject* element = root->value.as_array.values[i]; | 2308 // Double values are expected to not be canonicalized in messages. |
2298 EXPECT_EQ(root->value.as_array.values[0], element); | 2309 EXPECT_EQ(Dart_CObject_kDouble, element->type); |
2310 EXPECT_EQ(3.14, element->value.as_double); | |
2311 for (int i = 1; i < kArrayLength; i++) { | |
2312 element = root->value.as_array.values[i]; | |
2313 // Double values are expected to not be canonicalized in messages. | |
2314 EXPECT_NE(root->value.as_array.values[0], element); | |
2299 EXPECT_EQ(Dart_CObject_kDouble, element->type); | 2315 EXPECT_EQ(Dart_CObject_kDouble, element->type); |
2300 EXPECT_EQ(3.14, element->value.as_double); | 2316 EXPECT_EQ(3.14, element->value.as_double); |
2301 } | 2317 } |
2302 } | 2318 } |
2303 { | 2319 { |
2304 // Generate a list of Uint8Lists from Dart code. | 2320 // Generate a list of Uint8Lists from Dart code. |
2305 ApiNativeScope scope; | 2321 ApiNativeScope scope; |
2306 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList"); | 2322 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList"); |
2307 EXPECT_NOTNULL(root); | 2323 EXPECT_NOTNULL(root); |
2308 EXPECT_EQ(Dart_CObject_kArray, root->type); | 2324 EXPECT_EQ(Dart_CObject_kArray, root->type); |
(...skipping 24 matching lines...) Expand all Loading... | |
2333 EXPECT_EQ(0, element->value.as_typed_data.values[1]); | 2349 EXPECT_EQ(0, element->value.as_typed_data.values[1]); |
2334 } | 2350 } |
2335 } | 2351 } |
2336 { | 2352 { |
2337 // Generate a list of objects of different types from Dart code. | 2353 // Generate a list of objects of different types from Dart code. |
2338 ApiNativeScope scope; | 2354 ApiNativeScope scope; |
2339 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList"); | 2355 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList"); |
2340 EXPECT_NOTNULL(root); | 2356 EXPECT_NOTNULL(root); |
2341 EXPECT_EQ(Dart_CObject_kArray, root->type); | 2357 EXPECT_EQ(Dart_CObject_kArray, root->type); |
2342 EXPECT_EQ(kArrayLength, root->value.as_array.length); | 2358 EXPECT_EQ(kArrayLength, root->value.as_array.length); |
2343 for (int i = 0; i < kArrayLength; i++) { | 2359 Dart_CObject* element = root->value.as_array.values[0]; |
2360 EXPECT_EQ(Dart_CObject_kString, element->type); | |
2361 EXPECT_STREQ(".", element->value.as_string); | |
2362 element = root->value.as_array.values[1]; | |
2363 EXPECT_EQ(Dart_CObject_kDouble, element->type); | |
2364 EXPECT_STREQ(2.72, element->value.as_double); | |
2365 for (int i = 2; i < kArrayLength; i++) { | |
2344 Dart_CObject* element = root->value.as_array.values[i]; | 2366 Dart_CObject* element = root->value.as_array.values[i]; |
2345 if ((i % 2) == 0) { | 2367 if ((i % 2) == 0) { |
2346 EXPECT_EQ(root->value.as_array.values[0], element); | 2368 EXPECT_EQ(root->value.as_array.values[0], element); |
2347 EXPECT_EQ(Dart_CObject_kString, element->type); | 2369 EXPECT_EQ(Dart_CObject_kString, element->type); |
2348 EXPECT_STREQ(".", element->value.as_string); | 2370 EXPECT_STREQ(".", element->value.as_string); |
2349 } else { | 2371 } else { |
2350 EXPECT_EQ(root->value.as_array.values[1], element); | 2372 // Double values are expected to not be canonicalized in messages. |
2373 EXPECT_NE(root->value.as_array.values[1], element); | |
2351 EXPECT_EQ(Dart_CObject_kDouble, element->type); | 2374 EXPECT_EQ(Dart_CObject_kDouble, element->type); |
2352 EXPECT_STREQ(2.72, element->value.as_double); | 2375 EXPECT_STREQ(2.72, element->value.as_double); |
2353 } | 2376 } |
2354 } | 2377 } |
2355 } | 2378 } |
2356 { | 2379 { |
2357 // Generate a list of objects of different types from Dart code. | 2380 // Generate a list of objects of different types from Dart code. |
2358 ApiNativeScope scope; | 2381 ApiNativeScope scope; |
2359 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList"); | 2382 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList"); |
2360 EXPECT_NOTNULL(root); | 2383 EXPECT_NOTNULL(root); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2685 result = Dart_RunLoop(); | 2708 result = Dart_RunLoop(); |
2686 EXPECT(Dart_IsError(result)); | 2709 EXPECT(Dart_IsError(result)); |
2687 EXPECT(Dart_ErrorHasException(result)); | 2710 EXPECT(Dart_ErrorHasException(result)); |
2688 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2711 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
2689 Dart_GetError(result)); | 2712 Dart_GetError(result)); |
2690 | 2713 |
2691 Dart_ExitScope(); | 2714 Dart_ExitScope(); |
2692 } | 2715 } |
2693 | 2716 |
2694 } // namespace dart | 2717 } // namespace dart |
OLD | NEW |