Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/assert.h" | 5 #include "vm/assert.h" |
| 6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1586 | 1586 |
| 1587 other_array = Array::New(kArrayLen - 1); | 1587 other_array = Array::New(kArrayLen - 1); |
| 1588 other_array.SetAt(0, array); | 1588 other_array.SetAt(0, array); |
| 1589 other_array.SetAt(2, array); | 1589 other_array.SetAt(2, array); |
| 1590 EXPECT(!array.Equals(other_array)); | 1590 EXPECT(!array.Equals(other_array)); |
| 1591 | 1591 |
| 1592 EXPECT_EQ(0, Array::Handle(Array::Empty()).Length()); | 1592 EXPECT_EQ(0, Array::Handle(Array::Empty()).Length()); |
| 1593 } | 1593 } |
| 1594 | 1594 |
| 1595 | 1595 |
| 1596 TEST_CASE(ExternalArray) { | |
| 1597 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3 }; | |
| 1598 intptr_t data_length = ARRAY_SIZE(data); | |
| 1599 | |
| 1600 const ExternalArray& array1 = | |
| 1601 ExternalArray::Handle(ExternalArray::New(data, data_length)); | |
| 1602 EXPECT(!array1.IsNull()); | |
| 1603 EXPECT_EQ(data_length, array1.Length()); | |
| 1604 EXPECT_EQ(-3, array1.Int8At(0)); | |
| 1605 EXPECT_EQ(253, array1.Uint8At(0)); | |
| 1606 EXPECT_EQ(-2, array1.Int8At(1)); | |
| 1607 EXPECT_EQ(254, array1.Uint8At(1)); | |
| 1608 EXPECT_EQ(-1, array1.Int8At(2)); | |
| 1609 EXPECT_EQ(255, array1.Uint8At(2)); | |
| 1610 EXPECT_EQ(0, array1.Int8At(3)); | |
| 1611 EXPECT_EQ(0, array1.Uint8At(3)); | |
| 1612 EXPECT_EQ(1, array1.Int8At(4)); | |
| 1613 EXPECT_EQ(1, array1.Uint8At(4)); | |
| 1614 EXPECT_EQ(2, array1.Int8At(5)); | |
| 1615 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
| |
| 1616 | |
| 1617 const ExternalArray& array2 = | |
| 1618 ExternalArray::Handle(ExternalArray::New(data, data_length)); | |
| 1619 EXPECT(!array1.IsNull()); | |
| 1620 EXPECT_EQ(data_length, array2.Length()); | |
| 1621 EXPECT(array1.Equals(array2)); | |
| 1622 EXPECT(array2.Equals(array1)); | |
| 1623 array1.SetUint8At(0, 123); | |
| 1624 array2.SetInt8At(2, -123); | |
| 1625 EXPECT(array1.Equals(array2)); | |
| 1626 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.
| |
| 1627 } | |
| 1628 | |
| 1629 | |
| 1596 TEST_CASE(Script) { | 1630 TEST_CASE(Script) { |
| 1597 const char* url_chars = "builtin:test-case"; | 1631 const char* url_chars = "builtin:test-case"; |
| 1598 const char* source_chars = "This will not compile."; | 1632 const char* source_chars = "This will not compile."; |
| 1599 const String& url = String::Handle(String::New(url_chars)); | 1633 const String& url = String::Handle(String::New(url_chars)); |
| 1600 const String& source = String::Handle(String::New(source_chars)); | 1634 const String& source = String::Handle(String::New(source_chars)); |
| 1601 const Script& script = Script::Handle(Script::New(url, | 1635 const Script& script = Script::Handle(Script::New(url, |
| 1602 source, | 1636 source, |
| 1603 RawScript::kSource)); | 1637 RawScript::kSource)); |
| 1604 EXPECT(!script.IsNull()); | 1638 EXPECT(!script.IsNull()); |
| 1605 EXPECT(script.IsScript()); | 1639 EXPECT(script.IsScript()); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1950 cls = iterator.GetNextClass(); | 1984 cls = iterator.GetNextClass(); |
| 1951 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw())); | 1985 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw())); |
| 1952 count++; | 1986 count++; |
| 1953 } | 1987 } |
| 1954 ASSERT(count == 2); | 1988 ASSERT(count == 2); |
| 1955 } | 1989 } |
| 1956 | 1990 |
| 1957 #endif // TARGET_ARCH_IA32. | 1991 #endif // TARGET_ARCH_IA32. |
| 1958 | 1992 |
| 1959 } // namespace dart | 1993 } // namespace dart |
| OLD | NEW |