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

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

Issue 2992093002: [vm] Several unit tests are corrected for limited ints (Closed)
Patch Set: Add explanation for chosen value as comment Created 3 years, 4 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
« no previous file with comments | « no previous file | runtime/vm/snapshot_test.cc » ('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 #include "vm/dart_api_impl.h" 5 #include "vm/dart_api_impl.h"
6 #include "bin/builtin.h" 6 #include "bin/builtin.h"
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 5322 matching lines...) Expand 10 before | Expand all | Expand 10 after
5333 arg_values[7].as_native_fields.values = native_fields2; 5333 arg_values[7].as_native_fields.values = native_fields2;
5334 Dart_Handle result = 5334 Dart_Handle result =
5335 Dart_GetNativeArguments(args, 9, arg_descriptors, arg_values); 5335 Dart_GetNativeArguments(args, 9, arg_descriptors, arg_values);
5336 EXPECT_VALID(result); 5336 EXPECT_VALID(result);
5337 5337
5338 EXPECT(arg_values[0].as_native_fields.values[0] == 30); 5338 EXPECT(arg_values[0].as_native_fields.values[0] == 30);
5339 EXPECT(arg_values[0].as_native_fields.values[1] == 40); 5339 EXPECT(arg_values[0].as_native_fields.values[1] == 40);
5340 5340
5341 EXPECT(arg_values[1].as_int32 == 77); 5341 EXPECT(arg_values[1].as_int32 == 77);
5342 5342
5343 EXPECT(arg_values[2].as_uint64 == 0xffffffffffffffffLL); 5343 // Note: this particular value is chosen for the following reasons.
5344 // 1) When wrapped-around, it should not fit into int32, because this unit
5345 // test verifies that getting it as int32 produces error.
5346 // 2) It should be large enough to exercise Bigints with unlimited ints, so
5347 // it should be > MaxInt64.
5348 // Given these constraints, any value between MaxInt64+1 and
5349 // MaxUint64-MaxInt32-1 would work. Value 0x8000000000000000 is in this
5350 // range and easy to produce without using a large integer literal.
5351 EXPECT(arg_values[2].as_uint64 == 0x8000000000000000LL);
5344 5352
5345 EXPECT(arg_values[3].as_bool == true); 5353 EXPECT(arg_values[3].as_bool == true);
5346 5354
5347 EXPECT(arg_values[4].as_double == 3.14); 5355 EXPECT(arg_values[4].as_double == 3.14);
5348 5356
5349 EXPECT_VALID(arg_values[5].as_string.dart_str); 5357 EXPECT_VALID(arg_values[5].as_string.dart_str);
5350 EXPECT(Dart_IsString(arg_values[5].as_string.dart_str)); 5358 EXPECT(Dart_IsString(arg_values[5].as_string.dart_str));
5351 EXPECT_VALID(Dart_StringToCString(arg_values[5].as_string.dart_str, &cstr)); 5359 EXPECT_VALID(Dart_StringToCString(arg_values[5].as_string.dart_str, &cstr));
5352 EXPECT_STREQ("abcdefg", cstr); 5360 EXPECT_STREQ("abcdefg", cstr);
5353 EXPECT(arg_values[5].as_string.peer == NULL); 5361 EXPECT(arg_values[5].as_string.peer == NULL);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
5439 " double arg4," 5447 " double arg4,"
5440 " String arg5," 5448 " String arg5,"
5441 " String arg6," 5449 " String arg6,"
5442 " MyObject arg7) native 'NativeArgument_Access';" 5450 " MyObject arg7) native 'NativeArgument_Access';"
5443 "}" 5451 "}"
5444 "int testMain(String extstr) {" 5452 "int testMain(String extstr) {"
5445 " String str = 'abcdefg';" 5453 " String str = 'abcdefg';"
5446 " MyObject obj1 = MyObject.createObject();" 5454 " MyObject obj1 = MyObject.createObject();"
5447 " MyObject obj2 = MyObject.createObject();" 5455 " MyObject obj2 = MyObject.createObject();"
5448 " return obj1.accessFields(77," 5456 " return obj1.accessFields(77,"
5449 " 0xffffffffffffffff," 5457 " 1 << 63,"
5450 " true," 5458 " true,"
5451 " 3.14," 5459 " 3.14,"
5452 " str," 5460 " str,"
5453 " extstr," 5461 " extstr,"
5454 " obj2);" 5462 " obj2);"
5455 "}"; 5463 "}";
5456 5464
5457 Dart_Handle lib = TestCase::LoadTestScript( 5465 Dart_Handle lib = TestCase::LoadTestScript(
5458 kScriptChars, 5466 kScriptChars,
5459 reinterpret_cast<Dart_NativeEntryResolver>(native_args_lookup)); 5467 reinterpret_cast<Dart_NativeEntryResolver>(native_args_lookup));
(...skipping 4162 matching lines...) Expand 10 before | Expand all | Expand 10 after
9622 EXPECT_VALID(result); 9630 EXPECT_VALID(result);
9623 result = Dart_FinalizeLoading(false); 9631 result = Dart_FinalizeLoading(false);
9624 EXPECT_VALID(result); 9632 EXPECT_VALID(result);
9625 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); 9633 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL);
9626 EXPECT(Dart_IsError(result)); 9634 EXPECT(Dart_IsError(result));
9627 } 9635 }
9628 9636
9629 #endif // !PRODUCT 9637 #endif // !PRODUCT
9630 9638
9631 } // namespace dart 9639 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698