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

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

Issue 2982753002: Fix bug in Dart API Dart_IntegerToUint64: crash on negative Mints (Closed)
Patch Set: Created 3 years, 5 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 | « runtime/vm/dart_api_impl.cc ('k') | no next file » | 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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 result = Dart_Invoke(lib, NewString("getNull"), 0, NULL); 861 result = Dart_Invoke(lib, NewString("getNull"), 0, NULL);
862 EXPECT_VALID(result); 862 EXPECT_VALID(result);
863 EXPECT(!Dart_IsNumber(result)); 863 EXPECT(!Dart_IsNumber(result));
864 } 864 }
865 865
866 TEST_CASE(IntegerValues) { 866 TEST_CASE(IntegerValues) {
867 const int64_t kIntegerVal1 = 100; 867 const int64_t kIntegerVal1 = 100;
868 const int64_t kIntegerVal2 = 0xffffffff; 868 const int64_t kIntegerVal2 = 0xffffffff;
869 const char* kIntegerVal3 = "0x123456789123456789123456789"; 869 const char* kIntegerVal3 = "0x123456789123456789123456789";
870 const uint64_t kIntegerVal4 = 0xffffffffffffffff; 870 const uint64_t kIntegerVal4 = 0xffffffffffffffff;
871 const int64_t kIntegerVal5 = -0x7fffffffffffffff;
871 872
872 Dart_Handle val1 = Dart_NewInteger(kIntegerVal1); 873 Dart_Handle val1 = Dart_NewInteger(kIntegerVal1);
873 EXPECT(Dart_IsInteger(val1)); 874 EXPECT(Dart_IsInteger(val1));
874 bool fits = false; 875 bool fits = false;
875 Dart_Handle result = Dart_IntegerFitsIntoInt64(val1, &fits); 876 Dart_Handle result = Dart_IntegerFitsIntoInt64(val1, &fits);
876 EXPECT_VALID(result); 877 EXPECT_VALID(result);
877 EXPECT(fits); 878 EXPECT(fits);
878 879
879 Dart_Handle val2 = Dart_NewInteger(kIntegerVal2); 880 Dart_Handle val2 = Dart_NewInteger(kIntegerVal2);
880 EXPECT(Dart_IsInteger(val2)); 881 EXPECT(Dart_IsInteger(val2));
(...skipping 26 matching lines...) Expand all
907 uint64_t out4 = 0; 908 uint64_t out4 = 0;
908 result = Dart_IntegerToUint64(val4, &out4); 909 result = Dart_IntegerToUint64(val4, &out4);
909 EXPECT_VALID(result); 910 EXPECT_VALID(result);
910 EXPECT_EQ(kIntegerVal4, out4); 911 EXPECT_EQ(kIntegerVal4, out4);
911 912
912 Dart_Handle val5 = Dart_NewInteger(-1); 913 Dart_Handle val5 = Dart_NewInteger(-1);
913 EXPECT_VALID(val5); 914 EXPECT_VALID(val5);
914 uint64_t out5 = 0; 915 uint64_t out5 = 0;
915 result = Dart_IntegerToUint64(val5, &out5); 916 result = Dart_IntegerToUint64(val5, &out5);
916 EXPECT(Dart_IsError(result)); 917 EXPECT(Dart_IsError(result));
918
919 Dart_Handle val6 = Dart_NewInteger(kIntegerVal5);
920 EXPECT_VALID(val6);
921 uint64_t out6 = 0;
922 result = Dart_IntegerToUint64(val6, &out6);
923 EXPECT(Dart_IsError(result));
917 } 924 }
918 925
919 TEST_CASE(IntegerFitsIntoInt64) { 926 TEST_CASE(IntegerFitsIntoInt64) {
920 Dart_Handle max = Dart_NewInteger(kMaxInt64); 927 Dart_Handle max = Dart_NewInteger(kMaxInt64);
921 EXPECT(Dart_IsInteger(max)); 928 EXPECT(Dart_IsInteger(max));
922 bool fits = false; 929 bool fits = false;
923 Dart_Handle result = Dart_IntegerFitsIntoInt64(max, &fits); 930 Dart_Handle result = Dart_IntegerFitsIntoInt64(max, &fits);
924 EXPECT_VALID(result); 931 EXPECT_VALID(result);
925 EXPECT(fits); 932 EXPECT(fits);
926 933
(...skipping 8700 matching lines...) Expand 10 before | Expand all | Expand 10 after
9627 EXPECT_VALID(result); 9634 EXPECT_VALID(result);
9628 result = Dart_FinalizeLoading(false); 9635 result = Dart_FinalizeLoading(false);
9629 EXPECT_VALID(result); 9636 EXPECT_VALID(result);
9630 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); 9637 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL);
9631 EXPECT(Dart_IsError(result)); 9638 EXPECT(Dart_IsError(result));
9632 } 9639 }
9633 9640
9634 #endif // !PRODUCT 9641 #endif // !PRODUCT
9635 9642
9636 } // namespace dart 9643 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698