Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: runtime/vm/snapshot_test.cc

Issue 221973004: - Handle doubles transferred in message snapshots specially. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/snapshot_ids.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(zra): Remove when tests are ready to enable. 5 // TODO(zra): Remove when tests are ready to enable.
6 #include "platform/globals.h" 6 #include "platform/globals.h"
7 #if !defined(TARGET_ARCH_ARM64) 7 #if !defined(TARGET_ARCH_ARM64)
8 8
9 #include "include/dart_debugger_api.h" 9 #include "include/dart_debugger_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 element->value.as_bigint); 2086 element->value.as_bigint);
2087 } 2087 }
2088 } 2088 }
2089 { 2089 {
2090 // Generate a list of doubles from Dart code. 2090 // Generate a list of doubles from Dart code.
2091 ApiNativeScope scope; 2091 ApiNativeScope scope;
2092 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList"); 2092 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList");
2093 EXPECT_NOTNULL(root); 2093 EXPECT_NOTNULL(root);
2094 EXPECT_EQ(Dart_CObject_kArray, root->type); 2094 EXPECT_EQ(Dart_CObject_kArray, root->type);
2095 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2095 EXPECT_EQ(kArrayLength, root->value.as_array.length);
2096 for (int i = 0; i < kArrayLength; i++) { 2096 Dart_CObject* element = root->value.as_array.values[0];
2097 Dart_CObject* element = root->value.as_array.values[i]; 2097 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2098 EXPECT_EQ(root->value.as_array.values[0], element); 2098 EXPECT_EQ(3.14, element->value.as_double);
2099 for (int i = 1; i < kArrayLength; i++) {
2100 element = root->value.as_array.values[i];
2101 // Double values are expected to not be canonicalized in messages.
2102 EXPECT_NE(root->value.as_array.values[0], element);
2099 EXPECT_EQ(Dart_CObject_kDouble, element->type); 2103 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2100 EXPECT_EQ(3.14, element->value.as_double); 2104 EXPECT_EQ(3.14, element->value.as_double);
2101 } 2105 }
2102 } 2106 }
2103 { 2107 {
2104 // Generate a list of Uint8Lists from Dart code. 2108 // Generate a list of Uint8Lists from Dart code.
2105 ApiNativeScope scope; 2109 ApiNativeScope scope;
2106 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList"); 2110 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList");
2107 EXPECT_NOTNULL(root); 2111 EXPECT_NOTNULL(root);
2108 EXPECT_EQ(Dart_CObject_kArray, root->type); 2112 EXPECT_EQ(Dart_CObject_kArray, root->type);
(...skipping 24 matching lines...) Expand all
2133 EXPECT_EQ(0, element->value.as_typed_data.values[1]); 2137 EXPECT_EQ(0, element->value.as_typed_data.values[1]);
2134 } 2138 }
2135 } 2139 }
2136 { 2140 {
2137 // Generate a list of objects of different types from Dart code. 2141 // Generate a list of objects of different types from Dart code.
2138 ApiNativeScope scope; 2142 ApiNativeScope scope;
2139 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList"); 2143 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList");
2140 EXPECT_NOTNULL(root); 2144 EXPECT_NOTNULL(root);
2141 EXPECT_EQ(Dart_CObject_kArray, root->type); 2145 EXPECT_EQ(Dart_CObject_kArray, root->type);
2142 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2146 EXPECT_EQ(kArrayLength, root->value.as_array.length);
2143 for (int i = 0; i < kArrayLength; i++) { 2147 Dart_CObject* element = root->value.as_array.values[0];
2144 Dart_CObject* element = root->value.as_array.values[i]; 2148 EXPECT_EQ(Dart_CObject_kString, element->type);
2149 EXPECT_STREQ("A", element->value.as_string);
2150 element = root->value.as_array.values[1];
2151 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2152 EXPECT_STREQ(2.72, element->value.as_double);
2153 for (int i = 2; i < kArrayLength; i++) {
2154 element = root->value.as_array.values[i];
2145 if ((i % 2) == 0) { 2155 if ((i % 2) == 0) {
2146 EXPECT_EQ(root->value.as_array.values[0], element); 2156 EXPECT_EQ(root->value.as_array.values[0], element);
2147 EXPECT_EQ(Dart_CObject_kString, element->type); 2157 EXPECT_EQ(Dart_CObject_kString, element->type);
2148 EXPECT_STREQ("A", element->value.as_string); 2158 EXPECT_STREQ("A", element->value.as_string);
2149 } else { 2159 } else {
2150 EXPECT_EQ(root->value.as_array.values[1], element); 2160 // Double values are expected to not be canonicalized in messages.
2161 EXPECT_NE(root->value.as_array.values[1], element);
2151 EXPECT_EQ(Dart_CObject_kDouble, element->type); 2162 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2152 EXPECT_STREQ(2.72, element->value.as_double); 2163 EXPECT_STREQ(2.72, element->value.as_double);
2153 } 2164 }
2154 } 2165 }
2155 } 2166 }
2156 { 2167 {
2157 // Generate a list of objects of different types from Dart code. 2168 // Generate a list of objects of different types from Dart code.
2158 ApiNativeScope scope; 2169 ApiNativeScope scope;
2159 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList"); 2170 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList");
2160 EXPECT_NOTNULL(root); 2171 EXPECT_NOTNULL(root);
(...skipping 29 matching lines...) Expand all
2190 "}\n" 2201 "}\n"
2191 "getBigintList() {\n" 2202 "getBigintList() {\n"
2192 " var bigint = 0x1234567890123456789012345678901234567890;\n" 2203 " var bigint = 0x1234567890123456789012345678901234567890;\n"
2193 " var list = [bigint, bigint, bigint, bigint, bigint,\n" 2204 " var list = [bigint, bigint, bigint, bigint, bigint,\n"
2194 " bigint, bigint, bigint, bigint, bigint];\n" 2205 " bigint, bigint, bigint, bigint, bigint];\n"
2195 " return list;\n" 2206 " return list;\n"
2196 "}\n" 2207 "}\n"
2197 "getDoubleList() {\n" 2208 "getDoubleList() {\n"
2198 " var d = 3.14;\n" 2209 " var d = 3.14;\n"
2199 " var list = [3.14, 3.14, 3.14, 3.14, 3.14, 3.14];\n" 2210 " var list = [3.14, 3.14, 3.14, 3.14, 3.14, 3.14];\n"
2200 " list.add(3.14);;\n" 2211 " list.add(3.14);\n"
2201 " list.add(3.14);;\n" 2212 " list.add(3.14);\n"
2202 " list.add(3.14);;\n" 2213 " list.add(3.14);\n"
2203 " list.add(3.14);;\n" 2214 " list.add(3.14);\n"
2204 " return list;\n" 2215 " return list;\n"
2205 "}\n" 2216 "}\n"
2206 "getTypedDataList() {\n" 2217 "getTypedDataList() {\n"
2207 " var byte_array = new Uint8List(256);\n" 2218 " var byte_array = new Uint8List(256);\n"
2208 " var list = [];\n" 2219 " var list = [];\n"
2209 " for (var i = 0; i < kArrayLength; i++) {\n" 2220 " for (var i = 0; i < kArrayLength; i++) {\n"
2210 " list.add(byte_array);\n" 2221 " list.add(byte_array);\n"
2211 " }\n" 2222 " }\n"
2212 " return list;\n" 2223 " return list;\n"
2213 "}\n" 2224 "}\n"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 element->value.as_bigint); 2301 element->value.as_bigint);
2291 } 2302 }
2292 } 2303 }
2293 { 2304 {
2294 // Generate a list of doubles from Dart code. 2305 // Generate a list of doubles from Dart code.
2295 ApiNativeScope scope; 2306 ApiNativeScope scope;
2296 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList"); 2307 Dart_CObject* root = GetDeserializedDartMessage(lib, "getDoubleList");
2297 EXPECT_NOTNULL(root); 2308 EXPECT_NOTNULL(root);
2298 EXPECT_EQ(Dart_CObject_kArray, root->type); 2309 EXPECT_EQ(Dart_CObject_kArray, root->type);
2299 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2310 EXPECT_EQ(kArrayLength, root->value.as_array.length);
2300 for (int i = 0; i < kArrayLength; i++) { 2311 Dart_CObject* element = root->value.as_array.values[0];
2301 Dart_CObject* element = root->value.as_array.values[i]; 2312 // Double values are expected to not be canonicalized in messages.
2302 EXPECT_EQ(root->value.as_array.values[0], element); 2313 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2314 EXPECT_EQ(3.14, element->value.as_double);
2315 for (int i = 1; i < kArrayLength; i++) {
2316 element = root->value.as_array.values[i];
2317 // Double values are expected to not be canonicalized in messages.
2318 EXPECT_NE(root->value.as_array.values[0], element);
2303 EXPECT_EQ(Dart_CObject_kDouble, element->type); 2319 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2304 EXPECT_EQ(3.14, element->value.as_double); 2320 EXPECT_EQ(3.14, element->value.as_double);
2305 } 2321 }
2306 } 2322 }
2307 { 2323 {
2308 // Generate a list of Uint8Lists from Dart code. 2324 // Generate a list of Uint8Lists from Dart code.
2309 ApiNativeScope scope; 2325 ApiNativeScope scope;
2310 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList"); 2326 Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList");
2311 EXPECT_NOTNULL(root); 2327 EXPECT_NOTNULL(root);
2312 EXPECT_EQ(Dart_CObject_kArray, root->type); 2328 EXPECT_EQ(Dart_CObject_kArray, root->type);
(...skipping 24 matching lines...) Expand all
2337 EXPECT_EQ(0, element->value.as_typed_data.values[1]); 2353 EXPECT_EQ(0, element->value.as_typed_data.values[1]);
2338 } 2354 }
2339 } 2355 }
2340 { 2356 {
2341 // Generate a list of objects of different types from Dart code. 2357 // Generate a list of objects of different types from Dart code.
2342 ApiNativeScope scope; 2358 ApiNativeScope scope;
2343 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList"); 2359 Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList");
2344 EXPECT_NOTNULL(root); 2360 EXPECT_NOTNULL(root);
2345 EXPECT_EQ(Dart_CObject_kArray, root->type); 2361 EXPECT_EQ(Dart_CObject_kArray, root->type);
2346 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2362 EXPECT_EQ(kArrayLength, root->value.as_array.length);
2347 for (int i = 0; i < kArrayLength; i++) { 2363 Dart_CObject* element = root->value.as_array.values[0];
2364 EXPECT_EQ(Dart_CObject_kString, element->type);
2365 EXPECT_STREQ(".", element->value.as_string);
2366 element = root->value.as_array.values[1];
2367 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2368 EXPECT_STREQ(2.72, element->value.as_double);
2369 for (int i = 2; i < kArrayLength; i++) {
2348 Dart_CObject* element = root->value.as_array.values[i]; 2370 Dart_CObject* element = root->value.as_array.values[i];
2349 if ((i % 2) == 0) { 2371 if ((i % 2) == 0) {
2350 EXPECT_EQ(root->value.as_array.values[0], element); 2372 EXPECT_EQ(root->value.as_array.values[0], element);
2351 EXPECT_EQ(Dart_CObject_kString, element->type); 2373 EXPECT_EQ(Dart_CObject_kString, element->type);
2352 EXPECT_STREQ(".", element->value.as_string); 2374 EXPECT_STREQ(".", element->value.as_string);
2353 } else { 2375 } else {
2354 EXPECT_EQ(root->value.as_array.values[1], element); 2376 // Double values are expected to not be canonicalized in messages.
2377 EXPECT_NE(root->value.as_array.values[1], element);
2355 EXPECT_EQ(Dart_CObject_kDouble, element->type); 2378 EXPECT_EQ(Dart_CObject_kDouble, element->type);
2356 EXPECT_STREQ(2.72, element->value.as_double); 2379 EXPECT_STREQ(2.72, element->value.as_double);
2357 } 2380 }
2358 } 2381 }
2359 } 2382 }
2360 { 2383 {
2361 // Generate a list of objects of different types from Dart code. 2384 // Generate a list of objects of different types from Dart code.
2362 ApiNativeScope scope; 2385 ApiNativeScope scope;
2363 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList"); 2386 Dart_CObject* root = GetDeserializedDartMessage(lib, "getSelfRefList");
2364 EXPECT_NOTNULL(root); 2387 EXPECT_NOTNULL(root);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 EXPECT(Dart_ErrorHasException(result)); 2714 EXPECT(Dart_ErrorHasException(result));
2692 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", 2715 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n",
2693 Dart_GetError(result)); 2716 Dart_GetError(result));
2694 2717
2695 Dart_ExitScope(); 2718 Dart_ExitScope();
2696 } 2719 }
2697 2720
2698 } // namespace dart 2721 } // namespace dart
2699 2722
2700 #endif // !defined(TARGET_ARCH_ARM64) 2723 #endif // !defined(TARGET_ARCH_ARM64)
OLDNEW
« no previous file with comments | « runtime/vm/snapshot_ids.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698