| OLD | NEW |
| 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/assembler.h" | 5 #include "vm/assembler.h" |
| 6 #include "vm/bigint_operations.h" | 6 #include "vm/bigint_operations.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 EXPECT(concat.Equals("\xC3\xB6\xC3\xB1\xC3\xA9\xC3\xB6\xC3\xB1\xC3\xA9")); | 1522 EXPECT(concat.Equals("\xC3\xB6\xC3\xB1\xC3\xA9\xC3\xB6\xC3\xB1\xC3\xA9")); |
| 1523 | 1523 |
| 1524 const String& substr = String::Handle(String::SubString(str, 1, 1)); | 1524 const String& substr = String::Handle(String::SubString(str, 1, 1)); |
| 1525 EXPECT(!substr.IsExternalOneByteString()); | 1525 EXPECT(!substr.IsExternalOneByteString()); |
| 1526 EXPECT(substr.IsOneByteString()); | 1526 EXPECT(substr.IsOneByteString()); |
| 1527 EXPECT_EQ(1, substr.Length()); | 1527 EXPECT_EQ(1, substr.Length()); |
| 1528 EXPECT(substr.Equals("\xC3\xB1")); | 1528 EXPECT(substr.Equals("\xC3\xB1")); |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 | 1531 |
| 1532 TEST_CASE(EscapeSpecialCharactersOneByteString) { |
| 1533 uint8_t characters[] = |
| 1534 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1535 intptr_t len = ARRAY_SIZE(characters); |
| 1536 |
| 1537 const String& str = |
| 1538 String::Handle( |
| 1539 OneByteString::New(characters, len, Heap::kNew)); |
| 1540 EXPECT(str.IsOneByteString()); |
| 1541 EXPECT_EQ(str.Length(), len); |
| 1542 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1543 const String& escaped_str = |
| 1544 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1545 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1546 |
| 1547 const String& empty_str = String::Handle(OneByteString::New(0, Heap::kNew)); |
| 1548 const String& escaped_empty_str = |
| 1549 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1550 EXPECT_EQ(empty_str.Length(), 0); |
| 1551 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1552 } |
| 1553 |
| 1554 |
| 1555 TEST_CASE(EscapeSpecialCharactersExternalOneByteString) { |
| 1556 uint8_t characters[] = |
| 1557 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1558 intptr_t len = ARRAY_SIZE(characters); |
| 1559 |
| 1560 const String& str = |
| 1561 String::Handle( |
| 1562 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1563 EXPECT(!str.IsOneByteString()); |
| 1564 EXPECT(str.IsExternalOneByteString()); |
| 1565 EXPECT_EQ(str.Length(), len); |
| 1566 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1567 const String& escaped_str = |
| 1568 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1569 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1570 |
| 1571 const String& empty_str = |
| 1572 String::Handle( |
| 1573 ExternalOneByteString::New(characters, 0, NULL, NULL, Heap::kNew)); |
| 1574 const String& escaped_empty_str = |
| 1575 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1576 EXPECT_EQ(empty_str.Length(), 0); |
| 1577 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1578 } |
| 1579 |
| 1580 TEST_CASE(EscapeSpecialCharactersTwoByteString) { |
| 1581 uint16_t characters[] = |
| 1582 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1583 intptr_t len = ARRAY_SIZE(characters); |
| 1584 |
| 1585 const String& str = |
| 1586 String::Handle(TwoByteString::New(characters, len, Heap::kNew)); |
| 1587 EXPECT(str.IsTwoByteString()); |
| 1588 EXPECT_EQ(str.Length(), len); |
| 1589 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1590 const String& escaped_str = |
| 1591 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1592 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1593 |
| 1594 const String& empty_str = String::Handle(TwoByteString::New(0, Heap::kNew)); |
| 1595 const String& escaped_empty_str = |
| 1596 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1597 EXPECT_EQ(empty_str.Length(), 0); |
| 1598 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1599 } |
| 1600 |
| 1601 |
| 1602 TEST_CASE(EscapeSpecialCharactersExternalTwoByteString) { |
| 1603 uint16_t characters[] = |
| 1604 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1605 intptr_t len = ARRAY_SIZE(characters); |
| 1606 |
| 1607 const String& str = |
| 1608 String::Handle( |
| 1609 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1610 EXPECT(str.IsExternalTwoByteString()); |
| 1611 EXPECT_EQ(str.Length(), len); |
| 1612 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1613 const String& escaped_str = |
| 1614 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1615 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1616 |
| 1617 const String& empty_str = |
| 1618 String::Handle( |
| 1619 ExternalTwoByteString::New(characters, 0, NULL, NULL, Heap::kNew)); |
| 1620 const String& escaped_empty_str = |
| 1621 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1622 EXPECT_EQ(empty_str.Length(), 0); |
| 1623 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1624 } |
| 1625 |
| 1626 |
| 1532 TEST_CASE(ExternalTwoByteString) { | 1627 TEST_CASE(ExternalTwoByteString) { |
| 1533 uint16_t characters[] = { 0x1E6B, 0x1E85, 0x1E53 }; | 1628 uint16_t characters[] = { 0x1E6B, 0x1E85, 0x1E53 }; |
| 1534 intptr_t len = ARRAY_SIZE(characters); | 1629 intptr_t len = ARRAY_SIZE(characters); |
| 1535 | 1630 |
| 1536 const String& str = | 1631 const String& str = |
| 1537 String::Handle( | 1632 String::Handle( |
| 1538 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1633 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1539 EXPECT(!str.IsTwoByteString()); | 1634 EXPECT(!str.IsTwoByteString()); |
| 1540 EXPECT(str.IsExternalTwoByteString()); | 1635 EXPECT(str.IsExternalTwoByteString()); |
| 1541 EXPECT_EQ(str.Length(), len); | 1636 EXPECT_EQ(str.Length(), len); |
| (...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3476 cls = Object::dynamic_class(); | 3571 cls = Object::dynamic_class(); |
| 3477 array = cls.fields(); | 3572 array = cls.fields(); |
| 3478 EXPECT(!array.IsNull()); | 3573 EXPECT(!array.IsNull()); |
| 3479 EXPECT(array.IsArray()); | 3574 EXPECT(array.IsArray()); |
| 3480 array = cls.functions(); | 3575 array = cls.functions(); |
| 3481 EXPECT(!array.IsNull()); | 3576 EXPECT(!array.IsNull()); |
| 3482 EXPECT(array.IsArray()); | 3577 EXPECT(array.IsArray()); |
| 3483 } | 3578 } |
| 3484 | 3579 |
| 3485 } // namespace dart | 3580 } // namespace dart |
| OLD | NEW |