OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @TestOn("vm") | 5 @TestOn("vm") |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 test("parses a valid double factor annotation", () { | 137 test("parses a valid double factor annotation", () { |
138 new File(_path).writeAsStringSync(""" | 138 new File(_path).writeAsStringSync(""" |
139 @Timeout.factor(0.5) | 139 @Timeout.factor(0.5) |
140 | 140 |
141 library foo; | 141 library foo; |
142 """); | 142 """); |
143 var metadata = parseMetadata(_path); | 143 var metadata = parseMetadata(_path); |
144 expect(metadata.timeout.scaleFactor, equals(0.5)); | 144 expect(metadata.timeout.scaleFactor, equals(0.5)); |
145 }); | 145 }); |
146 | 146 |
| 147 test("parses a valid Timeout.none annotation", () { |
| 148 new File(_path).writeAsStringSync(""" |
| 149 @Timeout.none |
| 150 |
| 151 library foo; |
| 152 """); |
| 153 var metadata = parseMetadata(_path); |
| 154 expect(metadata.timeout, same(Timeout.none)); |
| 155 }); |
| 156 |
147 test("ignores a constructor named Timeout", () { | 157 test("ignores a constructor named Timeout", () { |
148 new File(_path).writeAsStringSync("@foo.Timeout('foo')\nlibrary foo;"); | 158 new File(_path).writeAsStringSync("@foo.Timeout('foo')\nlibrary foo;"); |
149 var metadata = parseMetadata(_path); | 159 var metadata = parseMetadata(_path); |
150 expect(metadata.timeout.scaleFactor, equals(1)); | 160 expect(metadata.timeout.scaleFactor, equals(1)); |
151 }); | 161 }); |
152 | 162 |
153 group("throws an error for", () { | 163 group("throws an error for", () { |
154 test("an unknown named constructor", () { | 164 test("an unknown named constructor", () { |
155 new File(_path).writeAsStringSync("@Timeout.name('foo')\nlibrary foo;"); | 165 new File(_path).writeAsStringSync("@Timeout.name('foo')\nlibrary foo;"); |
156 expect(() => parseMetadata(_path), throwsFormatException); | 166 expect(() => parseMetadata(_path), throwsFormatException); |
157 }); | 167 }); |
158 | 168 |
159 test("no argument list", () { | 169 test("no argument list", () { |
160 new File(_path).writeAsStringSync("@Timeout\nlibrary foo;"); | 170 new File(_path).writeAsStringSync("@Timeout\nlibrary foo;"); |
161 expect(() => parseMetadata(_path), throwsFormatException); | 171 expect(() => parseMetadata(_path), throwsFormatException); |
162 }); | 172 }); |
163 | 173 |
164 test("an empty argument list", () { | 174 test("an empty argument list", () { |
165 new File(_path).writeAsStringSync("@Timeout()\nlibrary foo;"); | 175 new File(_path).writeAsStringSync("@Timeout()\nlibrary foo;"); |
166 expect(() => parseMetadata(_path), throwsFormatException); | 176 expect(() => parseMetadata(_path), throwsFormatException); |
167 }); | 177 }); |
168 | 178 |
| 179 test("an argument list for Timeout.none", () { |
| 180 new File(_path).writeAsStringSync("@Timeout.none()\nlibrary foo;"); |
| 181 expect(() => parseMetadata(_path), throwsFormatException); |
| 182 }); |
| 183 |
169 test("a named argument", () { | 184 test("a named argument", () { |
170 new File(_path).writeAsStringSync( | 185 new File(_path).writeAsStringSync( |
171 "@Timeout(duration: const Duration(seconds: 1))\nlibrary foo;"); | 186 "@Timeout(duration: const Duration(seconds: 1))\nlibrary foo;"); |
172 expect(() => parseMetadata(_path), throwsFormatException); | 187 expect(() => parseMetadata(_path), throwsFormatException); |
173 }); | 188 }); |
174 | 189 |
175 test("multiple arguments", () { | 190 test("multiple arguments", () { |
176 new File(_path).writeAsStringSync( | 191 new File(_path).writeAsStringSync( |
177 "@Timeout.factor(1, 2)\nlibrary foo;"); | 192 "@Timeout.factor(1, 2)\nlibrary foo;"); |
178 expect(() => parseMetadata(_path), throwsFormatException); | 193 expect(() => parseMetadata(_path), throwsFormatException); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 }); | 395 }); |
381 | 396 |
382 test("multiple @OnPlatforms", () { | 397 test("multiple @OnPlatforms", () { |
383 new File(_path).writeAsStringSync( | 398 new File(_path).writeAsStringSync( |
384 "@OnPlatform(const {})\n@OnPlatform(const {})\nlibrary foo;"); | 399 "@OnPlatform(const {})\n@OnPlatform(const {})\nlibrary foo;"); |
385 expect(() => parseMetadata(_path), throwsFormatException); | 400 expect(() => parseMetadata(_path), throwsFormatException); |
386 }); | 401 }); |
387 }); | 402 }); |
388 }); | 403 }); |
389 } | 404 } |
OLD | NEW |