Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "tools/gn/input_file.h" | 6 #include "tools/gn/input_file.h" |
| 7 #include "tools/gn/parse_tree.h" | 7 #include "tools/gn/parse_tree.h" |
| 8 #include "tools/gn/scope.h" | 8 #include "tools/gn/scope.h" |
| 9 #include "tools/gn/test_with_scope.h" | 9 #include "tools/gn/test_with_scope.h" |
| 10 | 10 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 input.parsed()->AsBlock()->statements()[0]->AsBinaryOp(); | 205 input.parsed()->AsBlock()->statements()[0]->AsBinaryOp(); |
| 206 ASSERT_TRUE(binop->right()->AsList()); | 206 ASSERT_TRUE(binop->right()->AsList()); |
| 207 const ListNode* list = binop->right()->AsList(); | 207 const ListNode* list = binop->right()->AsList(); |
| 208 EXPECT_EQ(3u, list->contents().size()); | 208 EXPECT_EQ(3u, list->contents().size()); |
| 209 auto ranges = list->GetSortRanges(); | 209 auto ranges = list->GetSortRanges(); |
| 210 ASSERT_EQ(1u, ranges.size()); | 210 ASSERT_EQ(1u, ranges.size()); |
| 211 EXPECT_EQ(1u, ranges[0].begin); | 211 EXPECT_EQ(1u, ranges[0].begin); |
| 212 EXPECT_EQ(3u, ranges[0].end); | 212 EXPECT_EQ(3u, ranges[0].end); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | |
| 216 TEST(ParseTree, Integers) { | |
| 217 const char *good[] = { | |
| 218 "0", | |
| 219 "10", | |
| 220 "-54321", | |
| 221 "9223372036854775807", | |
| 222 "-9223372036854775808", | |
| 223 }; | |
| 224 | |
| 225 const char *bad[] = { | |
|
brettw
2015/03/31 23:05:33
I think it would be better to move this to right a
mdempsky
2015/03/31 23:19:20
Done.
| |
| 226 "-0", | |
| 227 "010", | |
| 228 "-010", | |
| 229 "9223372036854775808", | |
| 230 "-9223372036854775809", | |
| 231 }; | |
| 232 | |
| 233 for (auto s : good) { | |
| 234 TestParseInput input(std::string("x = ") + s); | |
| 235 EXPECT_FALSE(input.has_error()); | |
| 236 | |
| 237 TestWithScope setup; | |
| 238 Err err; | |
| 239 input.parsed()->Execute(setup.scope(), &err); | |
| 240 EXPECT_FALSE(err.has_error()); | |
| 241 } | |
| 242 | |
| 243 for (auto s : bad) { | |
| 244 TestParseInput input(std::string("x = ") + s); | |
| 245 EXPECT_FALSE(input.has_error()); | |
| 246 | |
| 247 TestWithScope setup; | |
| 248 Err err; | |
| 249 input.parsed()->Execute(setup.scope(), &err); | |
| 250 EXPECT_TRUE(err.has_error()); | |
| 251 } | |
| 252 } | |
| OLD | NEW |