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

Unified Diff: runtime/vm/snapshot_test.cc

Issue 509153003: New bigint implementation in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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
Index: runtime/vm/snapshot_test.cc
===================================================================
--- runtime/vm/snapshot_test.cc (revision 40060)
+++ runtime/vm/snapshot_test.cc (working copy)
@@ -6,7 +6,6 @@
#include "include/dart_debugger_api.h"
#include "platform/assert.h"
-#include "vm/bigint_operations.h"
#include "vm/class_finalizer.h"
#include "vm/dart_api_impl.h"
#include "vm/dart_api_message.h"
@@ -87,9 +86,14 @@
case Dart_CObject_kInt64:
EXPECT_EQ(first->value.as_int64, second->value.as_int64);
break;
- case Dart_CObject_kBigint:
- EXPECT_STREQ(first->value.as_bigint, second->value.as_bigint);
+ case Dart_CObject_kBigint: {
+ char* first_hex_value = TestCase::BigintToHexValue(first);
+ char* second_hex_value = TestCase::BigintToHexValue(second);
+ EXPECT_STREQ(first_hex_value, second_hex_value);
+ free(first_hex_value);
+ free(second_hex_value);
break;
+ }
case Dart_CObject_kDouble:
EXPECT_EQ(first->value.as_double, second->value.as_double);
break;
@@ -397,17 +401,17 @@
Bigint& obj = Bigint::Handle();
obj ^= reader.ReadObject();
- EXPECT_STREQ(BigintOperations::ToHexCString(bigint, &allocator),
- BigintOperations::ToHexCString(obj, &allocator));
+ EXPECT_STREQ(bigint.ToHexCString(allocator), obj.ToHexCString(allocator));
// Read object back from the snapshot into a C structure.
ApiNativeScope scope;
ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator);
Dart_CObject* root = api_reader.ReadMessage();
- // Bigint not supported.
EXPECT_NOTNULL(root);
EXPECT_EQ(Dart_CObject_kBigint, root->type);
- EXPECT_STREQ("270FFFFFFFFFFFFFD8F0", root->value.as_bigint);
+ char* hex_value = TestCase::BigintToHexValue(root);
+ EXPECT_STREQ(cstr, hex_value);
+ free(hex_value);
CheckEncodeDecodeMessage(root);
}
@@ -424,9 +428,8 @@
Snapshot::kMessage, Isolate::Current());
Bigint& serialized_bigint = Bigint::Handle();
serialized_bigint ^= reader.ReadObject();
- const char* str1 = BigintOperations::ToHexCString(bigint, allocator);
- const char* str2 =
- BigintOperations::ToHexCString(serialized_bigint, allocator);
+ const char* str1 = bigint.ToHexCString(allocator);
+ const char* str2 = serialized_bigint.ToHexCString(allocator);
EXPECT_STREQ(str1, str2);
free(const_cast<char*>(str1));
free(const_cast<char*>(str2));
@@ -446,16 +449,12 @@
ApiNativeScope scope;
Bigint& bigint = Bigint::Handle();
- bigint ^= BigintOperations::NewFromCString(bigint_value);
+ bigint ^= Bigint::NewFromCString(bigint_value);
Dart_CObject* bigint_cobject = SerializeAndDeserializeBigint(bigint);
EXPECT_EQ(Dart_CObject_kBigint, bigint_cobject->type);
- if (bigint_value[0] == '0') {
- EXPECT_STREQ(bigint_value + 2, bigint_cobject->value.as_bigint);
- } else {
- EXPECT_EQ('-', bigint_value[0]);
- EXPECT_EQ('-', bigint_cobject->value.as_bigint[0]);
- EXPECT_STREQ(bigint_value + 3, bigint_cobject->value.as_bigint + 1);
- }
+ char* hex_value = TestCase::BigintToHexValue(bigint_cobject);
+ EXPECT_STREQ(bigint_value, hex_value);
+ free(hex_value);
}
@@ -1638,8 +1637,9 @@
Dart_CObject* root = api_reader.ReadMessage();
EXPECT_NOTNULL(root);
EXPECT_EQ(Dart_CObject_kBigint, root->type);
- EXPECT_STREQ("-424242424242424242424242424242424242",
- root->value.as_bigint);
+ char* hex_value = TestCase::BigintToHexValue(root);
+ EXPECT_STREQ("-0x424242424242424242424242424242424242", hex_value);
+ free(hex_value);
CheckEncodeDecodeMessage(root);
}
CheckString(ascii_string_result, "Hello, world!");
@@ -2085,8 +2085,9 @@
Dart_CObject* element = root->value.as_array.values[i];
EXPECT_EQ(root->value.as_array.values[0], element);
EXPECT_EQ(Dart_CObject_kBigint, element->type);
- EXPECT_STREQ("1234567890123456789012345678901234567890",
- element->value.as_bigint);
+ char* hex_value = TestCase::BigintToHexValue(element);
+ EXPECT_STREQ("0x1234567890123456789012345678901234567890", hex_value);
+ free(hex_value);
}
}
{
@@ -2300,8 +2301,9 @@
Dart_CObject* element = root->value.as_array.values[i];
EXPECT_EQ(root->value.as_array.values[0], element);
EXPECT_EQ(Dart_CObject_kBigint, element->type);
- EXPECT_STREQ("1234567890123456789012345678901234567890",
- element->value.as_bigint);
+ char* hex_value = TestCase::BigintToHexValue(element);
+ EXPECT_STREQ("0x1234567890123456789012345678901234567890", hex_value);
+ free(hex_value);
}
}
{
« runtime/lib/bigint.dart ('K') | « runtime/vm/snapshot.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698