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

Unified Diff: runtime/vm/object_test.cc

Issue 8429027: Add an external array type to support typed arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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/object_test.cc
diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc
index 8e2778d6371b2d9fd07a25edd40a449db84b6433..763bbacd242849c32a8e1e8ee82ca843ce551068 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -1593,6 +1593,40 @@ TEST_CASE(Array) {
}
+TEST_CASE(ExternalArray) {
+ uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3 };
+ intptr_t data_length = ARRAY_SIZE(data);
+
+ const ExternalArray& array1 =
+ ExternalArray::Handle(ExternalArray::New(data, data_length));
+ EXPECT(!array1.IsNull());
+ EXPECT_EQ(data_length, array1.Length());
+ EXPECT_EQ(-3, array1.Int8At(0));
+ EXPECT_EQ(253, array1.Uint8At(0));
+ EXPECT_EQ(-2, array1.Int8At(1));
+ EXPECT_EQ(254, array1.Uint8At(1));
+ EXPECT_EQ(-1, array1.Int8At(2));
+ EXPECT_EQ(255, array1.Uint8At(2));
+ EXPECT_EQ(0, array1.Int8At(3));
+ EXPECT_EQ(0, array1.Uint8At(3));
+ EXPECT_EQ(1, array1.Int8At(4));
+ EXPECT_EQ(1, array1.Uint8At(4));
+ EXPECT_EQ(2, array1.Int8At(5));
+ EXPECT_EQ(2, array1.Uint8At(5));
siva 2011/11/02 17:05:31 We probably need unit tests for get/set of other t
cshapiro 2011/11/04 18:16:21 It is not entirely clear how to do this. I have s
+
+ const ExternalArray& array2 =
+ ExternalArray::Handle(ExternalArray::New(data, data_length));
+ EXPECT(!array1.IsNull());
+ EXPECT_EQ(data_length, array2.Length());
+ EXPECT(array1.Equals(array2));
+ EXPECT(array2.Equals(array1));
+ array1.SetUint8At(0, 123);
+ array2.SetInt8At(2, -123);
+ EXPECT(array1.Equals(array2));
+ EXPECT(array2.Equals(array1));
siva 2011/11/02 17:05:31 We should set some different values and check that
cshapiro 2011/11/04 18:16:21 Absolutely. Done in the more recent patch set.
+}
+
+
TEST_CASE(Script) {
const char* url_chars = "builtin:test-case";
const char* source_chars = "This will not compile.";

Powered by Google App Engine
This is Rietveld 408576698