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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 }); | 221 }); |
222 | 222 |
223 test("a duplicate named argument", () { | 223 test("a duplicate named argument", () { |
224 new File(_path).writeAsStringSync( | 224 new File(_path).writeAsStringSync( |
225 "@Timeout(const Duration(seconds: 1, seconds: 1))\nlibrary foo;"); | 225 "@Timeout(const Duration(seconds: 1, seconds: 1))\nlibrary foo;"); |
226 expect(() => parseMetadata(_path), throwsFormatException); | 226 expect(() => parseMetadata(_path), throwsFormatException); |
227 }); | 227 }); |
228 }); | 228 }); |
229 }); | 229 }); |
230 }); | 230 }); |
| 231 |
| 232 group("@Skip:", () { |
| 233 test("parses a valid annotation", () { |
| 234 new File(_path).writeAsStringSync("@Skip()\nlibrary foo;"); |
| 235 var metadata = parseMetadata(_path); |
| 236 expect(metadata.skip, isTrue); |
| 237 expect(metadata.skipReason, isNull); |
| 238 }); |
| 239 |
| 240 test("parses a valid annotation with a reason", () { |
| 241 new File(_path).writeAsStringSync("@Skip('reason')\nlibrary foo;"); |
| 242 var metadata = parseMetadata(_path); |
| 243 expect(metadata.skip, isTrue); |
| 244 expect(metadata.skipReason, equals('reason')); |
| 245 }); |
| 246 |
| 247 test("ignores a constructor named Skip", () { |
| 248 new File(_path).writeAsStringSync("@foo.Skip('foo')\nlibrary foo;"); |
| 249 var metadata = parseMetadata(_path); |
| 250 expect(metadata.skip, isFalse); |
| 251 }); |
| 252 |
| 253 group("throws an error for", () { |
| 254 test("a named constructor", () { |
| 255 new File(_path).writeAsStringSync("@Skip.name('foo')\nlibrary foo;"); |
| 256 expect(() => parseMetadata(_path), throwsFormatException); |
| 257 }); |
| 258 |
| 259 test("no argument list", () { |
| 260 new File(_path).writeAsStringSync("@Skip\nlibrary foo;"); |
| 261 expect(() => parseMetadata(_path), throwsFormatException); |
| 262 }); |
| 263 |
| 264 test("a named argument", () { |
| 265 new File(_path).writeAsStringSync( |
| 266 "@Skip(reason: 'foo')\nlibrary foo;"); |
| 267 expect(() => parseMetadata(_path), throwsFormatException); |
| 268 }); |
| 269 |
| 270 test("multiple arguments", () { |
| 271 new File(_path).writeAsStringSync("@Skip('foo', 'bar')\nlibrary foo;"); |
| 272 expect(() => parseMetadata(_path), throwsFormatException); |
| 273 }); |
| 274 |
| 275 test("a non-string argument", () { |
| 276 new File(_path).writeAsStringSync("@Skip(123)\nlibrary foo;"); |
| 277 expect(() => parseMetadata(_path), throwsFormatException); |
| 278 }); |
| 279 |
| 280 test("multiple @Skips", () { |
| 281 new File(_path).writeAsStringSync( |
| 282 "@Skip('foo')\n@Skip('bar')\nlibrary foo;"); |
| 283 expect(() => parseMetadata(_path), throwsFormatException); |
| 284 }); |
| 285 }); |
| 286 }); |
231 } | 287 } |
OLD | NEW |