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

Side by Side Diff: test/backend/metadata_test.dart

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: address comments Created 5 years 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
« no previous file with comments | « test/backend/declarer_test.dart ('k') | test/runner/tag_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'package:test/src/backend/metadata.dart'; 5 import 'package:test/src/backend/metadata.dart';
6 import 'package:test/src/backend/test_platform.dart'; 6 import 'package:test/src/backend/test_platform.dart';
7 import 'package:test/src/frontend/timeout.dart'; 7 import 'package:test/src/frontend/timeout.dart';
8 import 'package:test/src/frontend/skip.dart'; 8 import 'package:test/src/frontend/skip.dart';
9 import 'package:test/test.dart'; 9 import 'package:test/test.dart';
10 10
11 void main() { 11 void main() {
12 group("Metadata", () {
13 void expectTags(tags, expected) {
14 expect(new Metadata.parse(tags: tags).tags, unorderedEquals(expected));
15
16 if (tags == null || tags is Iterable) {
17 expect(new Metadata(tags: tags).tags, unorderedEquals(expected));
18 }
19 }
20
21 void expectTagsError(tags) {
22 expect(() => new Metadata(tags: tags), throwsArgumentError);
23 expect(() => new Metadata.parse(tags: tags), throwsArgumentError);
24 }
25
26 test("takes no tags", () {
27 expectTags(null, []);
28 expectTags("", []);
29 expectTags([], []);
30 });
31
32 test("takes some tags as Iterable", () {
33 var tags = ["a", "b"];
34 expectTags(tags, tags);
35 expectTags(new Set.from(tags), tags);
36 });
37
38 test("takes some tags as String", () {
39 expectTags("a", ["a"]);
40 });
41
42 test("parse refuses bad tag types", () {
43 expect(() => new Metadata.parse(tags: 1), throwsArgumentError);
44 });
45
46 test("refuses non-String tag names", () {
47 expectTagsError([1]);
48 expectTagsError([null]);
49 });
50
51 test("refuses blank tag names", () {
52 expectTagsError([""]);
53 });
54
55 test("merges tags by computing the union of the two tag sets", () {
56 var merged = new Metadata(tags: ["a", "b"])
57 .merge(new Metadata(tags: ["b", "c"]));
58 expect(merged.tags, unorderedEquals(["a", "b", "c"]));
59 });
60
61 test("serializes tags to a List", () {
62 var serialized = new Metadata(tags: ["a", "b"]).serialize()['tags'];
63 expect(serialized, new isInstanceOf<List>());
64 expect(serialized, ["a", "b"]);
65 });
66
67 group('deserialize', () {
68 test('deserializes tags', () {
69 var serialized = {
70 "tags": ['a', 'b'],
71 "timeout": "none",
72 "onPlatform": [],
73 };
74 expect(new Metadata.deserialize(serialized).tags,
75 unorderedEquals(['a', 'b']));
76 });
77 });
78 });
79
12 group("onPlatform", () { 80 group("onPlatform", () {
13 test("parses a valid map", () { 81 test("parses a valid map", () {
14 var metadata = new Metadata.parse(onPlatform: { 82 var metadata = new Metadata.parse(onPlatform: {
15 "chrome": new Timeout.factor(2), 83 "chrome": new Timeout.factor(2),
16 "vm": [new Skip(), new Timeout.factor(3)] 84 "vm": [new Skip(), new Timeout.factor(3)]
17 }); 85 });
18 86
19 var key = metadata.onPlatform.keys.first; 87 var key = metadata.onPlatform.keys.first;
20 expect(key.evaluate(TestPlatform.chrome), isTrue); 88 expect(key.evaluate(TestPlatform.chrome), isTrue);
21 expect(key.evaluate(TestPlatform.vm), isFalse); 89 expect(key.evaluate(TestPlatform.vm), isFalse);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 }, throwsArgumentError); 124 }, throwsArgumentError);
57 }); 125 });
58 126
59 test("refuses multiple Skips", () { 127 test("refuses multiple Skips", () {
60 expect(() { 128 expect(() {
61 new Metadata.parse(onPlatform: {"chrome": [new Skip(), new Skip()]}); 129 new Metadata.parse(onPlatform: {"chrome": [new Skip(), new Skip()]});
62 }, throwsArgumentError); 130 }, throwsArgumentError);
63 }); 131 });
64 }); 132 });
65 } 133 }
OLDNEW
« no previous file with comments | « test/backend/declarer_test.dart ('k') | test/runner/tag_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698