OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/char-predicates.h" | 5 #include "src/char-predicates.h" |
6 #include "src/unicode.h" | 6 #include "src/unicode.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 TEST(CharPredicatesTest, WhiteSpace) { | 12 TEST(CharPredicatesTest, WhiteSpace) { |
13 // As of Unicode 6.3.0, \u180E is no longer a white space. We still consider | 13 // As of Unicode 6.3.0, \u180E is no longer a white space. We still consider |
14 // it to be one though, since JS recognizes all white spaces in Unicode 5.1. | 14 // it to be one though, since JS recognizes all white spaces in Unicode 5.1. |
15 EXPECT_TRUE(WhiteSpace::Is(0x0009)); | 15 EXPECT_TRUE(WhiteSpace::Is(0x0009)); |
16 EXPECT_TRUE(WhiteSpace::Is(0x000B)); | 16 EXPECT_TRUE(WhiteSpace::Is(0x000B)); |
17 EXPECT_TRUE(WhiteSpace::Is(0x000C)); | 17 EXPECT_TRUE(WhiteSpace::Is(0x000C)); |
18 EXPECT_TRUE(WhiteSpace::Is(' ')); | 18 EXPECT_TRUE(WhiteSpace::Is(' ')); |
19 EXPECT_TRUE(WhiteSpace::Is(0x00A0)); | 19 EXPECT_TRUE(WhiteSpace::Is(0x00A0)); |
20 EXPECT_TRUE(WhiteSpace::Is(0x180E)); | |
21 EXPECT_TRUE(WhiteSpace::Is(0xFEFF)); | 20 EXPECT_TRUE(WhiteSpace::Is(0xFEFF)); |
22 } | 21 } |
23 | 22 |
24 | 23 |
25 TEST(CharPredicatesTest, WhiteSpaceOrLineTerminator) { | 24 TEST(CharPredicatesTest, WhiteSpaceOrLineTerminator) { |
26 // As of Unicode 6.3.0, \u180E is no longer a white space. We still consider | 25 // As of Unicode 6.3.0, \u180E is no longer a white space. We still consider |
27 // it to be one though, since JS recognizes all white spaces in Unicode 5.1. | 26 // it to be one though, since JS recognizes all white spaces in Unicode 5.1. |
28 // White spaces | 27 // White spaces |
29 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x0009)); | 28 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x0009)); |
30 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000B)); | 29 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000B)); |
31 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000C)); | 30 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000C)); |
32 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(' ')); | 31 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(' ')); |
33 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x00A0)); | 32 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x00A0)); |
34 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x180E)); | |
35 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0xFEFF)); | 33 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0xFEFF)); |
36 // Line terminators | 34 // Line terminators |
37 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000A)); | 35 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000A)); |
38 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000D)); | 36 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x000D)); |
39 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x2028)); | 37 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x2028)); |
40 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x2029)); | 38 EXPECT_TRUE(WhiteSpaceOrLineTerminator::Is(0x2029)); |
41 } | 39 } |
42 | 40 |
43 | 41 |
44 TEST(CharPredicatesTest, IdentifierStart) { | 42 TEST(CharPredicatesTest, IdentifierStart) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Neither. | 110 // Neither. |
113 EXPECT_FALSE(IdentifierStart::Is(0x10111)); // Category No | 111 EXPECT_FALSE(IdentifierStart::Is(0x10111)); // Category No |
114 EXPECT_FALSE(IdentifierPart::Is(0x10111)); | 112 EXPECT_FALSE(IdentifierPart::Is(0x10111)); |
115 EXPECT_FALSE(IdentifierStart::Is(0x1F4A9)); // Category So | 113 EXPECT_FALSE(IdentifierStart::Is(0x1F4A9)); // Category So |
116 EXPECT_FALSE(IdentifierPart::Is(0x1F4A9)); | 114 EXPECT_FALSE(IdentifierPart::Is(0x1F4A9)); |
117 } | 115 } |
118 #endif // V8_I18N_SUPPORT | 116 #endif // V8_I18N_SUPPORT |
119 | 117 |
120 } // namespace internal | 118 } // namespace internal |
121 } // namespace v8 | 119 } // namespace v8 |
OLD | NEW |