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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 390004: Fix warnings on Win64. (Closed)
Patch Set: Created 11 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "token.h" 32 #include "token.h"
33 #include "scanner.h" 33 #include "scanner.h"
34 #include "utils.h"
34 35
35 #include "cctest.h" 36 #include "cctest.h"
36 37
37 namespace i = ::v8::internal; 38 namespace i = ::v8::internal;
38 39
39 TEST(KeywordMatcher) { 40 TEST(KeywordMatcher) {
40 struct KeywordToken { 41 struct KeywordToken {
41 const char* keyword; 42 const char* keyword;
42 i::Token::Value token; 43 i::Token::Value token;
43 }; 44 };
(...skipping 11 matching lines...) Expand all
55 TOKEN_LIST(IGNORE, IGNORE, FUTURE) 56 TOKEN_LIST(IGNORE, IGNORE, FUTURE)
56 #undef FUTURE 57 #undef FUTURE
57 #undef IGNORE 58 #undef IGNORE
58 NULL 59 NULL
59 }; 60 };
60 61
61 KeywordToken key_token; 62 KeywordToken key_token;
62 for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) { 63 for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) {
63 i::KeywordMatcher matcher; 64 i::KeywordMatcher matcher;
64 const char* keyword = key_token.keyword; 65 const char* keyword = key_token.keyword;
65 int length = strlen(keyword); 66 int length = i::StrLength(keyword);
66 for (int j = 0; j < length; j++) { 67 for (int j = 0; j < length; j++) {
67 if (key_token.token == i::Token::INSTANCEOF && j == 2) { 68 if (key_token.token == i::Token::INSTANCEOF && j == 2) {
68 // "in" is a prefix of "instanceof". It's the only keyword 69 // "in" is a prefix of "instanceof". It's the only keyword
69 // that is a prefix of another. 70 // that is a prefix of another.
70 CHECK_EQ(i::Token::IN, matcher.token()); 71 CHECK_EQ(i::Token::IN, matcher.token());
71 } else { 72 } else {
72 CHECK_EQ(i::Token::IDENTIFIER, matcher.token()); 73 CHECK_EQ(i::Token::IDENTIFIER, matcher.token());
73 } 74 }
74 matcher.AddChar(keyword[j]); 75 matcher.AddChar(keyword[j]);
75 } 76 }
76 CHECK_EQ(key_token.token, matcher.token()); 77 CHECK_EQ(key_token.token, matcher.token());
77 // Adding more characters will make keyword matching fail. 78 // Adding more characters will make keyword matching fail.
78 matcher.AddChar('z'); 79 matcher.AddChar('z');
79 CHECK_EQ(i::Token::IDENTIFIER, matcher.token()); 80 CHECK_EQ(i::Token::IDENTIFIER, matcher.token());
80 // Adding a keyword later will not make it match again. 81 // Adding a keyword later will not make it match again.
81 matcher.AddChar('i'); 82 matcher.AddChar('i');
82 matcher.AddChar('f'); 83 matcher.AddChar('f');
83 CHECK_EQ(i::Token::IDENTIFIER, matcher.token()); 84 CHECK_EQ(i::Token::IDENTIFIER, matcher.token());
84 } 85 }
85 86
86 // Future keywords are not recognized. 87 // Future keywords are not recognized.
87 const char* future_keyword; 88 const char* future_keyword;
88 for (int i = 0; (future_keyword = future_keywords[i]) != NULL; i++) { 89 for (int i = 0; (future_keyword = future_keywords[i]) != NULL; i++) {
89 i::KeywordMatcher matcher; 90 i::KeywordMatcher matcher;
90 int length = strlen(future_keyword); 91 int length = i::StrLength(future_keyword);
91 for (int j = 0; j < length; j++) { 92 for (int j = 0; j < length; j++) {
92 matcher.AddChar(future_keyword[j]); 93 matcher.AddChar(future_keyword[j]);
93 } 94 }
94 CHECK_EQ(i::Token::IDENTIFIER, matcher.token()); 95 CHECK_EQ(i::Token::IDENTIFIER, matcher.token());
95 } 96 }
96 97
97 // Zero isn't ignored at first. 98 // Zero isn't ignored at first.
98 i::KeywordMatcher bad_start; 99 i::KeywordMatcher bad_start;
99 bad_start.AddChar(0); 100 bad_start.AddChar(0);
100 CHECK_EQ(i::Token::IDENTIFIER, bad_start.token()); 101 CHECK_EQ(i::Token::IDENTIFIER, bad_start.token());
(...skipping 18 matching lines...) Expand all
119 // If we mark it as failure, continuing won't help. 120 // If we mark it as failure, continuing won't help.
120 i::KeywordMatcher full_stop; 121 i::KeywordMatcher full_stop;
121 full_stop.AddChar('i'); 122 full_stop.AddChar('i');
122 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 123 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
123 full_stop.Fail(); 124 full_stop.Fail();
124 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 125 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
125 full_stop.AddChar('f'); 126 full_stop.AddChar('f');
126 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 127 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
127 } 128 }
128 129
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698