| 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 #import("../../../css/css.dart"); | 5 #import("../../../css/css.dart"); |
| 6 #import('../../../../frog/lang.dart', prefix:'lang'); | |
| 7 | 6 |
| 8 class SelectorLiteralTest { | 7 class SelectorLiteralTest { |
| 9 static final String ERROR = 'CompilerException: <buffer>:'; | 8 static final String ERROR = 'CompilerException: <buffer>:'; |
| 10 | 9 |
| 11 static testMain() { | 10 static testMain() { |
| 12 initCssWorld(); | 11 initCssWorld(); |
| 13 lang.options.useColors = false; | 12 options.useColors = false; |
| 14 | 13 |
| 15 testSimpleClassSelectorSuccesses(); | 14 testSimpleClassSelectorSuccesses(); |
| 16 testSimpleClassSelectorFailures(); | 15 testSimpleClassSelectorFailures(); |
| 17 testPrivateNameFailures(); | 16 testPrivateNameFailures(); |
| 18 } | 17 } |
| 19 | 18 |
| 20 static void testSimpleClassSelectorSuccesses() { | 19 static void testSimpleClassSelectorSuccesses() { |
| 21 List<String> knownClasses = ['foobar', 'xyzzy', 'a-story', 'b-story']; | 20 List<String> knownClasses = ['foobar', 'xyzzy', 'a-story', 'b-story']; |
| 22 List<String> knownIds = ['id1', 'id2', 'id-number-3']; | 21 List<String> knownIds = ['id1', 'id2', 'id-number-3']; |
| 23 | 22 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Expect.equals("CssSelectorException: Unknown selector name .xyzzy1", | 82 Expect.equals("CssSelectorException: Unknown selector name .xyzzy1", |
| 84 e.toString()); | 83 e.toString()); |
| 85 } | 84 } |
| 86 | 85 |
| 87 // Test for invalid class name (can't start with number). | 86 // Test for invalid class name (can't start with number). |
| 88 css = '@{.foobar .1a-story .xyzzy}'; | 87 css = '@{.foobar .1a-story .xyzzy}'; |
| 89 try { | 88 try { |
| 90 cssParseAndValidate('${css}', cssWorld); | 89 cssParseAndValidate('${css}', cssWorld); |
| 91 Expect.fail("${css} should not succeed."); | 90 Expect.fail("${css} should not succeed."); |
| 92 } catch (final e) { | 91 } catch (final e) { |
| 93 Expect.equals("${ERROR}1:11: fatal: expected }, but found double(.1)\n" + | 92 Expect.equals("${ERROR}1:11: fatal: parsing error expected }\n" + |
| 94 "${css}\n ^^", e.toString()); | 93 "${css}\n ^^", e.toString()); |
| 95 } | 94 } |
| 96 | 95 |
| 97 // element id must be single selector. | 96 // element id must be single selector. |
| 98 css = '@{#id1 #id2}'; | 97 css = '@{#id1 #id2}'; |
| 99 try { | 98 try { |
| 100 cssParseAndValidate('${css}', cssWorld); | 99 cssParseAndValidate('${css}', cssWorld); |
| 101 Expect.fail("${css} should not succeed."); | 100 Expect.fail("${css} should not succeed."); |
| 102 } catch (final e) { | 101 } catch (final e) { |
| 103 Expect.equals("CssSelectorException: Use of Id selector must be " + | 102 Expect.equals("CssSelectorException: Use of Id selector must be " + |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 Expect.equals("CssSelectorException: Use of Id selector must be " + | 232 Expect.equals("CssSelectorException: Use of Id selector must be " + |
| 234 "singleton starting at #_privateId2", e.toString()); | 233 "singleton starting at #_privateId2", e.toString()); |
| 235 } | 234 } |
| 236 } | 235 } |
| 237 | 236 |
| 238 } | 237 } |
| 239 | 238 |
| 240 main() { | 239 main() { |
| 241 SelectorLiteralTest.testMain(); | 240 SelectorLiteralTest.testMain(); |
| 242 } | 241 } |
| OLD | NEW |