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

Side by Side Diff: utils/tests/pub/yaml_test.dart

Issue 11301046: Restructure pkg/unittest and pkg/webdriver to follow the pub conventions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « utils/tests/pub/version_test.dart ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #library('yaml_test'); 5 library yaml_test;
6 6
7 #import('dart:math'); 7 import 'dart:math';
8 8
9 #import('../../../pkg/unittest/unittest.dart'); 9 import '../../../pkg/unittest/lib/unittest.dart';
10 #import('../../pub/yaml/yaml.dart'); 10 import '../../pub/yaml/yaml.dart';
11 #import('../../pub/yaml/deep_equals.dart'); 11 import '../../pub/yaml/deep_equals.dart';
12 #import('../../../tests/utils/test_utils.dart'); 12 import '../../../tests/utils/test_utils.dart';
13 13
14 /** Constructs a new yaml.YamlMap, optionally from a normal Map. */ 14 /** Constructs a new yaml.YamlMap, optionally from a normal Map. */
15 Map yamlMap([Map from]) => 15 Map yamlMap([Map from]) =>
16 from == null ? new YamlMap() : new YamlMap.from(from); 16 from == null ? new YamlMap() : new YamlMap.from(from);
17 17
18 /** 18 /**
19 * Asserts that a string containing a single YAML document produces a given 19 * Asserts that a string containing a single YAML document produces a given
20 * value when loaded. 20 * value when loaded.
21 */ 21 */
22 expectYamlLoads(expected, String source) { 22 expectYamlLoads(expected, String source) {
(...skipping 14 matching lines...) Expand all
37 37
38 main() { 38 main() {
39 var infinity = parseDouble("Infinity"); 39 var infinity = parseDouble("Infinity");
40 var nan = parseDouble("NaN"); 40 var nan = parseDouble("NaN");
41 41
42 group('YamlMap', () { 42 group('YamlMap', () {
43 group('accepts as a key', () { 43 group('accepts as a key', () {
44 _expectKeyWorks(keyFn()) { 44 _expectKeyWorks(keyFn()) {
45 var map = yamlMap(); 45 var map = yamlMap();
46 map[keyFn()] = 5; 46 map[keyFn()] = 5;
47 Expect.isTrue(map.containsKey(keyFn())); 47 expect(map.containsKey(keyFn()), isTrue);
48 Expect.equals(5, map[keyFn()]); 48 expect(map[keyFn()], 5);
49 } 49 }
50 50
51 test('null', () => _expectKeyWorks(() => null)); 51 test('null', () => _expectKeyWorks(() => null));
52 test('true', () => _expectKeyWorks(() => true)); 52 test('true', () => _expectKeyWorks(() => true));
53 test('false', () => _expectKeyWorks(() => false)); 53 test('false', () => _expectKeyWorks(() => false));
54 test('a list', () => _expectKeyWorks(() => [1, 2, 3])); 54 test('a list', () => _expectKeyWorks(() => [1, 2, 3]));
55 test('a map', () => _expectKeyWorks(() => {'foo': 'bar'})); 55 test('a map', () => _expectKeyWorks(() => {'foo': 'bar'}));
56 test('a YAML map', () => _expectKeyWorks(() => yamlMap({'foo': 'bar'}))); 56 test('a YAML map', () => _expectKeyWorks(() => yamlMap({'foo': 'bar'})));
57 }); 57 });
58 58
59 test('works as a hash key', () { 59 test('works as a hash key', () {
60 var normalMap = new Map(); 60 var normalMap = new Map();
61 normalMap[yamlMap({'foo': 'bar'})] = 'baz'; 61 normalMap[yamlMap({'foo': 'bar'})] = 'baz';
62 Expect.isTrue(normalMap.containsKey(yamlMap({'foo': 'bar'}))); 62 expect(normalMap.containsKey(yamlMap({'foo': 'bar'})), isTrue);
63 Expect.equals('baz', normalMap[yamlMap({'foo': 'bar'})]); 63 expect(normalMap[yamlMap({'foo': 'bar'})], 'baz');
64 }); 64 });
65 65
66 test('treats YamlMap keys the same as normal maps', () { 66 test('treats YamlMap keys the same as normal maps', () {
67 var map = yamlMap(); 67 var map = yamlMap();
68 map[{'a': 'b'}] = 5; 68 map[{'a': 'b'}] = 5;
69 Expect.equals(5, map[yamlMap({'a': 'b'})]); 69 expect(map[yamlMap({'a': 'b'})], 5);
70 }); 70 });
71 }); 71 });
72 72
73 group('has a friendly error message for', () { 73 group('has a friendly error message for', () {
74 var tabError = predicate((e) => 74 var tabError = predicate((e) =>
75 e.toString().contains('tab characters are not allowed as indentation')); 75 e.toString().contains('tab characters are not allowed as indentation'));
76 76
77 test('using a tab as indentation', () { 77 test('using a tab as indentation', () {
78 expect(() => loadYaml('foo:\n\tbar'), 78 expect(() => loadYaml('foo:\n\tbar'),
79 throwsA(tabError)); 79 throwsA(tabError));
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 A null: null 1874 A null: null
1875 Also a null: # Empty 1875 Also a null: # Empty
1876 Not a null: "" 1876 Not a null: ""
1877 Booleans: [ true, True, false, FALSE ] 1877 Booleans: [ true, True, false, FALSE ]
1878 Integers: [ 0, 0o7, 0x3A, -19 ] 1878 Integers: [ 0, 0o7, 0x3A, -19 ]
1879 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] 1879 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ]
1880 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); 1880 Also floats: [ .inf, -.Inf, +.INF, .NAN ]''');
1881 }); 1881 });
1882 }); 1882 });
1883 } 1883 }
OLDNEW
« no previous file with comments | « utils/tests/pub/version_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698