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

Unified Diff: runtime/vm/snapshot_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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot_test.cc
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
index 0d387862100e1a7f6ca65d1b5264e2d4ded3ff34..5f35e94dee95aed93430760d7cb59fb1e8fb13e6 100644
--- a/runtime/vm/snapshot_test.cc
+++ b/runtime/vm/snapshot_test.cc
@@ -1855,13 +1855,10 @@ static void CheckStringInvalid(Dart_Handle dart_string) {
}
VM_UNIT_TEST_CASE(DartGeneratedMessages) {
- static const char* kCustomIsolateScriptChars =
+ static const char* kCustomIsolateScriptCommonChars =
"getSmi() {\n"
" return 42;\n"
"}\n"
- "getBigint() {\n"
- " return -0x424242424242424242424242424242424242;\n"
- "}\n"
"getAsciiString() {\n"
" return \"Hello, world!\";\n"
"}\n"
@@ -1886,20 +1883,33 @@ VM_UNIT_TEST_CASE(DartGeneratedMessages) {
"getList() {\n"
" return new List(kArrayLength);\n"
"}\n";
+ static const char* kCustomIsolateScriptBigintChars =
+ "getBigint() {\n"
+ " return -0x424242424242424242424242424242424242;\n"
+ "}\n";
TestCase::CreateTestIsolate();
Isolate* isolate = Isolate::Current();
EXPECT(isolate != NULL);
Dart_EnterScope();
- Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars, NULL);
+ const char* scriptChars = kCustomIsolateScriptCommonChars;
+ if (!Bigint::IsDisabled()) {
+ scriptChars = OS::SCreate(Thread::Current()->zone(), "%s%s", scriptChars,
+ kCustomIsolateScriptBigintChars);
+ }
+
+ Dart_Handle lib = TestCase::LoadTestScript(scriptChars, NULL);
EXPECT_VALID(lib);
Dart_Handle smi_result;
smi_result = Dart_Invoke(lib, NewString("getSmi"), 0, NULL);
EXPECT_VALID(smi_result);
- Dart_Handle bigint_result;
- bigint_result = Dart_Invoke(lib, NewString("getBigint"), 0, NULL);
- EXPECT_VALID(bigint_result);
+
+ Dart_Handle bigint_result = NULL;
+ if (!Bigint::IsDisabled()) {
+ bigint_result = Dart_Invoke(lib, NewString("getBigint"), 0, NULL);
+ EXPECT_VALID(bigint_result);
+ }
Dart_Handle ascii_string_result;
ascii_string_result = Dart_Invoke(lib, NewString("getAsciiString"), 0, NULL);
@@ -1965,7 +1975,7 @@ VM_UNIT_TEST_CASE(DartGeneratedMessages) {
EXPECT_EQ(42, root->value.as_int32);
CheckEncodeDecodeMessage(root);
}
- {
+ if (!Bigint::IsDisabled()) {
StackZone zone(thread);
Bigint& bigint = Bigint::Handle();
bigint ^= Api::UnwrapHandle(bigint_result);
@@ -2333,7 +2343,7 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessages) {
VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) {
const int kArrayLength = 10;
- static const char* kScriptChars =
+ static const char* kScriptCommonChars =
"import 'dart:typed_data';\n"
"final int kArrayLength = 10;\n"
"getStringList() {\n"
@@ -2348,12 +2358,6 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) {
" for (var i = 0; i < kArrayLength; i++) list[i] = mint;\n"
" return list;\n"
"}\n"
- "getBigintList() {\n"
- " var bigint = 0x1234567890123456789012345678901234567890;\n"
- " var list = new List(kArrayLength);\n"
- " for (var i = 0; i < kArrayLength; i++) list[i] = bigint;\n"
- " return list;\n"
- "}\n"
"getDoubleList() {\n"
" var d = 3.14;\n"
" var list = new List<double>(kArrayLength);\n"
@@ -2389,13 +2393,26 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) {
" }\n"
" return list;\n"
"}\n";
+ static const char* kScriptBigintChars =
+ "getBigintList() {\n"
+ " var bigint = 0x1234567890123456789012345678901234567890;\n"
+ " var list = new List(kArrayLength);\n"
+ " for (var i = 0; i < kArrayLength; i++) list[i] = bigint;\n"
+ " return list;\n"
+ "}\n";
TestCase::CreateTestIsolate();
Thread* thread = Thread::Current();
EXPECT(thread->isolate() != NULL);
Dart_EnterScope();
- Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ const char* scriptChars = kScriptCommonChars;
+ if (!Bigint::IsDisabled()) {
+ scriptChars =
+ OS::SCreate(thread->zone(), "%s%s", scriptChars, kScriptBigintChars);
+ }
+
+ Dart_Handle lib = TestCase::LoadTestScript(scriptChars, NULL);
EXPECT_VALID(lib);
{
@@ -2433,7 +2450,7 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) {
EXPECT_EQ(DART_INT64_C(0x7FFFFFFFFFFFFFFF), element->value.as_int64);
}
}
- {
+ if (!Bigint::IsDisabled()) {
// Generate a list of bigints from Dart code.
uint8_t* buf = GetSerialized(lib, "getBigintList", &buf_len);
ApiNativeScope scope;
@@ -2552,7 +2569,7 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) {
VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) {
const int kArrayLength = 10;
- static const char* kScriptChars =
+ static const char* kScriptCommonChars =
"import 'dart:typed_data';\n"
"final int kArrayLength = 10;\n"
"getStringList() {\n"
@@ -2566,12 +2583,6 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) {
" mint, mint, mint, mint, mint];\n"
" return list;\n"
"}\n"
- "getBigintList() {\n"
- " var bigint = 0x1234567890123456789012345678901234567890;\n"
- " var list = [bigint, bigint, bigint, bigint, bigint,\n"
- " bigint, bigint, bigint, bigint, bigint];\n"
- " return list;\n"
- "}\n"
"getDoubleList() {\n"
" var d = 3.14;\n"
" var list = [3.14, 3.14, 3.14, 3.14, 3.14, 3.14];\n"
@@ -2614,13 +2625,25 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) {
" }\n"
" return list;\n"
"}\n";
+ static const char* kScriptBigintChars =
+ "getBigintList() {\n"
+ " var bigint = 0x1234567890123456789012345678901234567890;\n"
+ " var list = [bigint, bigint, bigint, bigint, bigint,\n"
+ " bigint, bigint, bigint, bigint, bigint];\n"
+ " return list;\n"
+ "}\n";
TestCase::CreateTestIsolate();
Thread* thread = Thread::Current();
EXPECT(thread->isolate() != NULL);
Dart_EnterScope();
- Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ const char* scriptChars = kScriptCommonChars;
+ if (!Bigint::IsDisabled()) {
+ scriptChars =
+ OS::SCreate(thread->zone(), "%s%s", scriptChars, kScriptBigintChars);
+ }
+ Dart_Handle lib = TestCase::LoadTestScript(scriptChars, NULL);
EXPECT_VALID(lib);
{
@@ -2658,7 +2681,7 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) {
EXPECT_EQ(DART_INT64_C(0x7FFFFFFFFFFFFFFF), element->value.as_int64);
}
}
- {
+ if (!Bigint::IsDisabled()) {
// Generate a list of bigints from Dart code.
uint8_t* buf = GetSerialized(lib, "getBigintList", &buf_len);
ApiNativeScope scope;
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698