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

Side by Side Diff: mojo/public/dart/third_party/yaml/test/yaml_test.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 months 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library yaml.test;
6
7 import 'package:unittest/unittest.dart';
8 import 'package:yaml/yaml.dart';
9
10 import 'utils.dart';
11
12 main() {
13 var infinity = double.parse("Infinity");
14 var nan = double.parse("NaN");
15
16 group('has a friendly error message for', () {
17 var tabError = predicate((e) =>
18 e.toString().contains('Tab characters are not allowed as indentation'));
19
20 test('using a tab as indentation', () {
21 expect(() => loadYaml('foo:\n\tbar'),
22 throwsA(tabError));
23 });
24
25 test('using a tab not as indentation', () {
26 expect(() => loadYaml('''
27 "foo
28 \tbar"
29 error'''),
30 throwsA(isNot(tabError)));
31 });
32 });
33
34 group("refuses documents that declare version", () {
35 test("1.0", () {
36 expectYamlFails("""
37 %YAML 1.0
38 --- text
39 """);
40 });
41
42 test("1.3", () {
43 expectYamlFails("""
44 %YAML 1.3
45 --- text
46 """);
47 });
48
49 test("2.0", () {
50 expectYamlFails("""
51 %YAML 2.0
52 --- text
53 """);
54 });
55 });
56
57 // The following tests are all taken directly from the YAML spec
58 // (http://www.yaml.org/spec/1.2/spec.html). Most of them are code examples
59 // that are directly included in the spec, but additional tests are derived
60 // from the prose.
61
62 // A few examples from the spec are deliberately excluded, because they test
63 // features that this implementation doesn't intend to support (character
64 // encoding detection and user-defined tags). More tests are commented out,
65 // because they're intended to be supported but not yet implemented.
66
67 // Chapter 2 is just a preview of various Yaml documents. It's probably not
68 // necessary to test its examples, but it would be nice to test everything in
69 // the spec.
70 group('2.1: Collections', () {
71 test('[Example 2.1]', () {
72 expectYamlLoads(["Mark McGwire", "Sammy Sosa", "Ken Griffey"],
73 """
74 - Mark McGwire
75 - Sammy Sosa
76 - Ken Griffey""");
77 });
78
79 test('[Example 2.2]', () {
80 expectYamlLoads({"hr": 65, "avg": 0.278, "rbi": 147},
81 """
82 hr: 65 # Home runs
83 avg: 0.278 # Batting average
84 rbi: 147 # Runs Batted In""");
85 });
86
87 test('[Example 2.3]', () {
88 expectYamlLoads({
89 "american": ["Boston Red Sox", "Detroit Tigers", "New York Yankees"],
90 "national": ["New York Mets", "Chicago Cubs", "Atlanta Braves"],
91 },
92 """
93 american:
94 - Boston Red Sox
95 - Detroit Tigers
96 - New York Yankees
97 national:
98 - New York Mets
99 - Chicago Cubs
100 - Atlanta Braves""");
101 });
102
103 test('[Example 2.4]', () {
104 expectYamlLoads([
105 {"name": "Mark McGwire", "hr": 65, "avg": 0.278},
106 {"name": "Sammy Sosa", "hr": 63, "avg": 0.288},
107 ],
108 """
109 -
110 name: Mark McGwire
111 hr: 65
112 avg: 0.278
113 -
114 name: Sammy Sosa
115 hr: 63
116 avg: 0.288""");
117 });
118
119 test('[Example 2.5]', () {
120 expectYamlLoads([
121 ["name", "hr", "avg"],
122 ["Mark McGwire", 65, 0.278],
123 ["Sammy Sosa", 63, 0.288]
124 ],
125 """
126 - [name , hr, avg ]
127 - [Mark McGwire, 65, 0.278]
128 - [Sammy Sosa , 63, 0.288]""");
129 });
130
131 test('[Example 2.6]', () {
132 expectYamlLoads({
133 "Mark McGwire": {"hr": 65, "avg": 0.278},
134 "Sammy Sosa": {"hr": 63, "avg": 0.288}
135 },
136 """
137 Mark McGwire: {hr: 65, avg: 0.278}
138 Sammy Sosa: {
139 hr: 63,
140 avg: 0.288
141 }""");
142 });
143 });
144
145 group('2.2: Structures', () {
146 test('[Example 2.7]', () {
147 expectYamlStreamLoads([
148 ["Mark McGwire", "Sammy Sosa", "Ken Griffey"],
149 ["Chicago Cubs", "St Louis Cardinals"]
150 ],
151 """
152 # Ranking of 1998 home runs
153 ---
154 - Mark McGwire
155 - Sammy Sosa
156 - Ken Griffey
157
158 # Team ranking
159 ---
160 - Chicago Cubs
161 - St Louis Cardinals""");
162 });
163
164 test('[Example 2.8]', () {
165 expectYamlStreamLoads([
166 {"time": "20:03:20", "player": "Sammy Sosa", "action": "strike (miss)"},
167 {"time": "20:03:47", "player": "Sammy Sosa", "action": "grand slam"},
168 ],
169 """
170 ---
171 time: 20:03:20
172 player: Sammy Sosa
173 action: strike (miss)
174 ...
175 ---
176 time: 20:03:47
177 player: Sammy Sosa
178 action: grand slam
179 ...""");
180 });
181
182 test('[Example 2.9]', () {
183 expectYamlLoads({
184 "hr": ["Mark McGwire", "Sammy Sosa"],
185 "rbi": ["Sammy Sosa", "Ken Griffey"]
186 },
187 """
188 ---
189 hr: # 1998 hr ranking
190 - Mark McGwire
191 - Sammy Sosa
192 rbi:
193 # 1998 rbi ranking
194 - Sammy Sosa
195 - Ken Griffey""");
196 });
197
198 test('[Example 2.10]', () {
199 expectYamlLoads({
200 "hr": ["Mark McGwire", "Sammy Sosa"],
201 "rbi": ["Sammy Sosa", "Ken Griffey"]
202 },
203 """
204 ---
205 hr:
206 - Mark McGwire
207 # Following node labeled SS
208 - &SS Sammy Sosa
209 rbi:
210 - *SS # Subsequent occurrence
211 - Ken Griffey""");
212 });
213
214 test('[Example 2.11]', () {
215 var doc = deepEqualsMap();
216 doc[["Detroit Tigers", "Chicago cubs"]] = ["2001-07-23"];
217 doc[["New York Yankees", "Atlanta Braves"]] =
218 ["2001-07-02", "2001-08-12", "2001-08-14"];
219 expectYamlLoads(doc,
220 """
221 ? - Detroit Tigers
222 - Chicago cubs
223 :
224 - 2001-07-23
225
226 ? [ New York Yankees,
227 Atlanta Braves ]
228 : [ 2001-07-02, 2001-08-12,
229 2001-08-14 ]""");
230 });
231
232 test('[Example 2.12]', () {
233 expectYamlLoads([
234 {"item": "Super Hoop", "quantity": 1},
235 {"item": "Basketball", "quantity": 4},
236 {"item": "Big Shoes", "quantity": 1},
237 ],
238 """
239 ---
240 # Products purchased
241 - item : Super Hoop
242 quantity: 1
243 - item : Basketball
244 quantity: 4
245 - item : Big Shoes
246 quantity: 1""");
247 });
248 });
249
250 group('2.3: Scalars', () {
251 test('[Example 2.13]', () {
252 expectYamlLoads(
253 cleanUpLiteral(
254 """
255 \\//||\\/||
256 // || ||__"""),
257 """
258 # ASCII Art
259 --- |
260 \\//||\\/||
261 // || ||__""");
262 });
263
264 test('[Example 2.14]', () {
265 expectYamlLoads("Mark McGwire's year was crippled by a knee injury.",
266 """
267 --- >
268 Mark McGwire's
269 year was crippled
270 by a knee injury.""");
271 });
272
273 test('[Example 2.15]', () {
274 expectYamlLoads(
275 cleanUpLiteral(
276 """
277 Sammy Sosa completed another fine season with great stats.
278
279 63 Home Runs
280 0.288 Batting Average
281
282 What a year!"""),
283 """
284 >
285 Sammy Sosa completed another
286 fine season with great stats.
287
288 63 Home Runs
289 0.288 Batting Average
290
291 What a year!""");
292 });
293
294 test('[Example 2.16]', () {
295 expectYamlLoads({
296 "name": "Mark McGwire",
297 "accomplishment": "Mark set a major league home run record in 1998.\n",
298 "stats": "65 Home Runs\n0.278 Batting Average"
299 },
300 """
301 name: Mark McGwire
302 accomplishment: >
303 Mark set a major league
304 home run record in 1998.
305 stats: |
306 65 Home Runs
307 0.278 Batting Average""");
308 });
309
310 test('[Example 2.17]', () {
311 expectYamlLoads({
312 "unicode": "Sosa did fine.\u263A",
313 "control": "\b1998\t1999\t2000\n",
314 "hex esc": "\r\n is \r\n",
315 "single": '"Howdy!" he cried.',
316 "quoted": " # Not a 'comment'.",
317 "tie-fighter": "|\\-*-/|"
318 },
319 """
320 unicode: "Sosa did fine.\\u263A"
321 control: "\\b1998\\t1999\\t2000\\n"
322 hex esc: "\\x0d\\x0a is \\r\\n"
323
324 single: '"Howdy!" he cried.'
325 quoted: ' # Not a ''comment''.'
326 tie-fighter: '|\\-*-/|'""");
327 });
328
329 test('[Example 2.18]', () {
330 expectYamlLoads({
331 "plain": "This unquoted scalar spans many lines.",
332 "quoted": "So does this quoted scalar.\n"
333 },
334 '''
335 plain:
336 This unquoted scalar
337 spans many lines.
338
339 quoted: "So does this
340 quoted scalar.\\n"''');
341 });
342 });
343
344 group('2.4: Tags', () {
345 test('[Example 2.19]', () {
346 expectYamlLoads({
347 "canonical": 12345,
348 "decimal": 12345,
349 "octal": 12,
350 "hexadecimal": 12
351 },
352 """
353 canonical: 12345
354 decimal: +12345
355 octal: 0o14
356 hexadecimal: 0xC""");
357 });
358
359 test('[Example 2.20]', () {
360 expectYamlLoads({
361 "canonical": 1230.15,
362 "exponential": 1230.15,
363 "fixed": 1230.15,
364 "negative infinity": -infinity,
365 "not a number": nan
366 },
367 """
368 canonical: 1.23015e+3
369 exponential: 12.3015e+02
370 fixed: 1230.15
371 negative infinity: -.inf
372 not a number: .NaN""");
373 });
374
375 test('[Example 2.21]', () {
376 var doc = deepEqualsMap({
377 "booleans": [true, false],
378 "string": "012345"
379 });
380 doc[null] = null;
381 expectYamlLoads(doc,
382 """
383 null:
384 booleans: [ true, false ]
385 string: '012345'""");
386 });
387
388 // Examples 2.22 through 2.26 test custom tag URIs, which this
389 // implementation currently doesn't plan to support.
390 });
391
392 group('2.5 Full Length Example', () {
393 // Example 2.27 tests custom tag URIs, which this implementation currently
394 // doesn't plan to support.
395
396 test('[Example 2.28]', () {
397 expectYamlStreamLoads([
398 {
399 "Time": "2001-11-23 15:01:42 -5",
400 "User": "ed",
401 "Warning": "This is an error message for the log file"
402 },
403 {
404 "Time": "2001-11-23 15:02:31 -5",
405 "User": "ed",
406 "Warning": "A slightly different error message."
407 },
408 {
409 "DateTime": "2001-11-23 15:03:17 -5",
410 "User": "ed",
411 "Fatal": 'Unknown variable "bar"',
412 "Stack": [
413 {
414 "file": "TopClass.py",
415 "line": 23,
416 "code": 'x = MoreObject("345\\n")\n'
417 },
418 {"file": "MoreClass.py", "line": 58, "code": "foo = bar"}
419 ]
420 }
421 ],
422 """
423 ---
424 Time: 2001-11-23 15:01:42 -5
425 User: ed
426 Warning:
427 This is an error message
428 for the log file
429 ---
430 Time: 2001-11-23 15:02:31 -5
431 User: ed
432 Warning:
433 A slightly different error
434 message.
435 ---
436 DateTime: 2001-11-23 15:03:17 -5
437 User: ed
438 Fatal:
439 Unknown variable "bar"
440 Stack:
441 - file: TopClass.py
442 line: 23
443 code: |
444 x = MoreObject("345\\n")
445 - file: MoreClass.py
446 line: 58
447 code: |-
448 foo = bar""");
449 });
450 });
451
452 // Chapter 3 just talks about the structure of loading and dumping Yaml.
453 // Chapter 4 explains conventions used in the spec.
454
455 // Chapter 5: Characters
456 group('5.1: Character Set', () {
457 expectAllowsCharacter(int charCode) {
458 var char = new String.fromCharCodes([charCode]);
459 expectYamlLoads('The character "$char" is allowed',
460 'The character "$char" is allowed');
461 }
462
463 expectAllowsQuotedCharacter(int charCode) {
464 var char = new String.fromCharCodes([charCode]);
465 expectYamlLoads("The character '$char' is allowed",
466 '"The character \'$char\' is allowed"');
467 }
468
469 expectDisallowsCharacter(int charCode) {
470 var char = new String.fromCharCodes([charCode]);
471 expectYamlFails('The character "$char" is disallowed');
472 }
473
474 test("doesn't include C0 control characters", () {
475 expectDisallowsCharacter(0x0);
476 expectDisallowsCharacter(0x8);
477 expectDisallowsCharacter(0x1F);
478 });
479
480 test("includes TAB", () => expectAllowsCharacter(0x9));
481 test("doesn't include DEL", () => expectDisallowsCharacter(0x7F));
482
483 test("doesn't include C1 control characters", () {
484 expectDisallowsCharacter(0x80);
485 expectDisallowsCharacter(0x8A);
486 expectDisallowsCharacter(0x9F);
487 });
488
489 test("includes NEL", () => expectAllowsCharacter(0x85));
490
491 group("within quoted strings", () {
492 test("includes DEL", () => expectAllowsQuotedCharacter(0x7F));
493 test("includes C1 control characters", () {
494 expectAllowsQuotedCharacter(0x80);
495 expectAllowsQuotedCharacter(0x8A);
496 expectAllowsQuotedCharacter(0x9F);
497 });
498 });
499 });
500
501 // Skipping section 5.2 (Character Encodings), since at the moment the module
502 // assumes that the client code is providing it with a string of the proper
503 // encoding.
504
505 group('5.3: Indicator Characters', () {
506 test('[Example 5.3]', () {
507 expectYamlLoads({
508 'sequence': ['one', 'two'],
509 'mapping': {'sky': 'blue', 'sea': 'green'}
510 },
511 """
512 sequence:
513 - one
514 - two
515 mapping:
516 ? sky
517 : blue
518 sea : green""");
519 });
520
521 test('[Example 5.4]', () {
522 expectYamlLoads({
523 'sequence': ['one', 'two'],
524 'mapping': {'sky': 'blue', 'sea': 'green'}
525 },
526 """
527 sequence: [ one, two, ]
528 mapping: { sky: blue, sea: green }""");
529 });
530
531 test('[Example 5.5]', () => expectYamlLoads(null, "# Comment only."));
532
533 // Skipping 5.6 because it uses an undefined tag.
534
535 test('[Example 5.7]', () {
536 expectYamlLoads({
537 'literal': "some\ntext\n",
538 'folded': "some text\n"
539 },
540 """
541 literal: |
542 some
543 text
544 folded: >
545 some
546 text
547 """);
548 });
549
550 test('[Example 5.8]', () {
551 expectYamlLoads({
552 'single': "text",
553 'double': "text"
554 },
555 """
556 single: 'text'
557 double: "text"
558 """);
559 });
560
561 test('[Example 5.9]', () {
562 expectYamlLoads("text",
563 """
564 %YAML 1.2
565 --- text""");
566 });
567
568 test('[Example 5.10]', () {
569 expectYamlFails("commercial-at: @text");
570 expectYamlFails("commercial-at: `text");
571 });
572 });
573
574 group('5.4: Line Break Characters', () {
575 group('include', () {
576 test('\\n', () => expectYamlLoads([1, 2], indentLiteral("- 1\n- 2")));
577 test('\\r', () => expectYamlLoads([1, 2], "- 1\r- 2"));
578 });
579
580 group('do not include', () {
581 test('form feed', () => expectYamlFails("- 1\x0C- 2"));
582 test('NEL', () => expectYamlLoads(["1\x85- 2"], "- 1\x85- 2"));
583 test('0x2028', () => expectYamlLoads(["1\u2028- 2"], "- 1\u2028- 2"));
584 test('0x2029', () => expectYamlLoads(["1\u2029- 2"], "- 1\u2029- 2"));
585 });
586
587 group('in a scalar context must be normalized', () {
588 test("from \\r to \\n", () =>
589 expectYamlLoads(["foo\nbar"], indentLiteral('- |\n foo\r bar')));
590 test("from \\r\\n to \\n", () =>
591 expectYamlLoads(["foo\nbar"], indentLiteral('- |\n foo\r\n bar'))) ;
592 });
593
594 test('[Example 5.11]', () {
595 expectYamlLoads(
596 cleanUpLiteral("""
597 Line break (no glyph)
598 Line break (glyphed)"""),
599 """
600 |
601 Line break (no glyph)
602 Line break (glyphed)""");
603 });
604 });
605
606 group('5.5: White Space Characters', () {
607 test('[Example 5.12]', () {
608 expectYamlLoads({
609 "quoted": "Quoted \t",
610 "block": 'void main() {\n\tprintf("Hello, world!\\n");\n}\n'
611 },
612 """
613 # Tabs and spaces
614 quoted: "Quoted \t"
615 block:\t|
616 void main() {
617 \tprintf("Hello, world!\\n");
618 }
619 """);
620 });
621 });
622
623 group('5.7: Escaped Characters', () {
624 test('[Example 5.13]', () {
625 expectYamlLoads(
626 "Fun with \x5C "
627 "\x22 \x07 \x08 \x1B \x0C "
628 "\x0A \x0D \x09 \x0B \x00 "
629 "\x20 \xA0 \x85 \u2028 \u2029 "
630 "A A A",
631 '''
632 "Fun with \\\\
633 \\" \\a \\b \\e \\f \\
634 \\n \\r \\t \\v \\0 \\
635 \\ \\_ \\N \\L \\P \\
636 \\x41 \\u0041 \\U00000041"''');
637 });
638
639 test('[Example 5.14]', () {
640 expectYamlFails('Bad escape: "\\c"');
641 expectYamlFails('Bad escape: "\\xq-"');
642 });
643 });
644
645 // Chapter 6: Basic Structures
646 group('6.1: Indentation Spaces', () {
647 test('may not include TAB characters', () {
648 expectYamlFails(
649 """
650 -
651 \t- foo
652 \t- bar""");
653 });
654
655 test('must be the same for all sibling nodes', () {
656 expectYamlFails(
657 """
658 -
659 - foo
660 - bar""");
661 });
662
663 test('may be different for the children of sibling nodes', () {
664 expectYamlLoads([["foo"], ["bar"]],
665 """
666 -
667 - foo
668 -
669 - bar""");
670 });
671
672 test('[Example 6.1]', () {
673 expectYamlLoads({
674 "Not indented": {
675 "By one space": "By four\n spaces\n",
676 "Flow style": [
677 "By two",
678 "Also by two",
679 "Still by two"
680 ]
681 }
682 },
683 """
684 # Leading comment line spaces are
685 # neither content nor indentation.
686
687 Not indented:
688 By one space: |
689 By four
690 spaces
691 Flow style: [ # Leading spaces
692 By two, # in flow style
693 Also by two, # are neither
694 \tStill by two # content nor
695 ] # indentation.""");
696 });
697
698 test('[Example 6.2]', () {
699 expectYamlLoads({'a': ['b', ['c', 'd']]},
700 """
701 ? a
702 : -\tb
703 - -\tc
704 - d""");
705 });
706 });
707
708 group('6.2: Separation Spaces', () {
709 test('[Example 6.3]', () {
710 expectYamlLoads([{'foo': 'bar'}, ['baz', 'baz']],
711 """
712 - foo:\t bar
713 - - baz
714 -\tbaz""");
715 });
716 });
717
718 group('6.3: Line Prefixes', () {
719 test('[Example 6.4]', () {
720 expectYamlLoads({
721 "plain": "text lines",
722 "quoted": "text lines",
723 "block": "text\n \tlines\n"
724 },
725 """
726 plain: text
727 lines
728 quoted: "text
729 \tlines"
730 block: |
731 text
732 \tlines
733 """);
734 });
735 });
736
737 group('6.4: Empty Lines', () {
738 test('[Example 6.5]', () {
739 expectYamlLoads({
740 "Folding": "Empty line\nas a line feed",
741 "Chomping": "Clipped empty lines\n",
742 },
743 """
744 Folding:
745 "Empty line
746 \t
747 as a line feed"
748 Chomping: |
749 Clipped empty lines
750 """);
751 });
752 });
753
754 group('6.5: Line Folding', () {
755 test('[Example 6.6]', () {
756 expectYamlLoads("trimmed\n\n\nas space",
757 """
758 >-
759 trimmed
760
761
762
763 as
764 space
765 """);
766 });
767
768 test('[Example 6.7]', () {
769 expectYamlLoads("foo \n\n\t bar\n\nbaz\n",
770 """
771 >
772 foo
773
774 \t bar
775
776 baz
777 """);
778 });
779
780 test('[Example 6.8]', () {
781 expectYamlLoads(" foo\nbar\nbaz ",
782 '''
783 "
784 foo
785
786 \t bar
787
788 baz
789 "''');
790 });
791 });
792
793 group('6.6: Comments', () {
794 test('must be separated from other tokens by white space characters', () {
795 expectYamlLoads("foo#bar", "foo#bar");
796 expectYamlLoads("foo:#bar", "foo:#bar");
797 expectYamlLoads("-#bar", "-#bar");
798 });
799
800 test('[Example 6.9]', () {
801 expectYamlLoads({'key': 'value'},
802 """
803 key: # Comment
804 value""");
805 });
806
807 group('outside of scalar content', () {
808 test('may appear on a line of their own', () {
809 expectYamlLoads([1, 2],
810 """
811 - 1
812 # Comment
813 - 2""");
814 });
815
816 test('are independent of indentation level', () {
817 expectYamlLoads([[1, 2]],
818 """
819 -
820 - 1
821 # Comment
822 - 2""");
823 });
824
825 test('include lines containing only white space characters', () {
826 expectYamlLoads([1, 2],
827 """
828 - 1
829 \t
830 - 2""");
831 });
832 });
833
834 group('within scalar content', () {
835 test('may not appear on a line of their own', () {
836 expectYamlLoads(["foo\n# not comment\nbar\n"],
837 """
838 - |
839 foo
840 # not comment
841 bar
842 """);
843 });
844
845 test("don't include lines containing only white space characters", () {
846 expectYamlLoads(["foo\n \t \nbar\n"],
847 """
848 - |
849 foo
850 \t
851 bar
852 """);
853 });
854 });
855
856 test('[Example 6.10]', () {
857 expectYamlLoads(null,
858 """
859 # Comment
860
861 """);
862 });
863
864 test('[Example 6.11]', () {
865 expectYamlLoads({'key': 'value'},
866 """
867 key: # Comment
868 # lines
869 value
870 """);
871 });
872
873 group('ending a block scalar header', () {
874 test('may not be followed by additional comment lines', () {
875 expectYamlLoads(["# not comment\nfoo\n"],
876 """
877 - | # comment
878 # not comment
879 foo
880 """);
881 });
882 });
883 });
884
885 group('6.7: Separation Lines', () {
886 test('may not be used within implicit keys', () {
887 expectYamlFails(
888 """
889 [1,
890 2]: 3""");
891 });
892
893 test('[Example 6.12]', () {
894 var doc = deepEqualsMap();
895 doc[{'first': 'Sammy', 'last': 'Sosa'}] = {
896 'hr': 65,
897 'avg': 0.278
898 };
899 expectYamlLoads(doc,
900 """
901 { first: Sammy, last: Sosa }:
902 # Statistics:
903 hr: # Home runs
904 65
905 avg: # Average
906 0.278""");
907 });
908 });
909
910 group('6.8: Directives', () {
911 // TODO(nweiz): assert that this produces a warning
912 test('[Example 6.13]', () {
913 expectYamlLoads("foo",
914 '''
915 %FOO bar baz # Should be ignored
916 # with a warning.
917 --- "foo"''');
918 });
919
920 // TODO(nweiz): assert that this produces a warning.
921 test('[Example 6.14]', () {
922 expectYamlLoads("foo",
923 '''
924 %YAML 1.3 # Attempt parsing
925 # with a warning
926 ---
927 "foo"''');
928 });
929
930 test('[Example 6.15]', () {
931 expectYamlFails(
932 """
933 %YAML 1.2
934 %YAML 1.1
935 foo""");
936 });
937
938 test('[Example 6.16]', () {
939 expectYamlLoads("foo",
940 '''
941 %TAG !yaml! tag:yaml.org,2002:
942 ---
943 !yaml!str "foo"''');
944 });
945
946 test('[Example 6.17]', () {
947 expectYamlFails(
948 """
949 %TAG ! !foo
950 %TAG ! !foo
951 bar""");
952 });
953
954 // Examples 6.18 through 6.22 test custom tag URIs, which this
955 // implementation currently doesn't plan to support.
956 });
957
958 group('6.9: Node Properties', () {
959 test('may be specified in any order', () {
960 expectYamlLoads(["foo", "bar"],
961 """
962 - !!str &a1 foo
963 - &a2 !!str bar""");
964 });
965
966 test('[Example 6.23]', () {
967 expectYamlLoads({
968 "foo": "bar",
969 "baz": "foo"
970 },
971 '''
972 !!str &a1 "foo":
973 !!str bar
974 &a2 baz : *a1''');
975 });
976
977 // Example 6.24 tests custom tag URIs, which this implementation currently
978 // doesn't plan to support.
979
980 test('[Example 6.25]', () {
981 expectYamlFails("- !<!> foo");
982 expectYamlFails("- !<\$:?> foo");
983 });
984
985 // Examples 6.26 and 6.27 test custom tag URIs, which this implementation
986 // currently doesn't plan to support.
987
988 test('[Example 6.28]', () {
989 expectYamlLoads(["12", 12, "12"],
990 '''
991 # Assuming conventional resolution:
992 - "12"
993 - 12
994 - ! 12''');
995 });
996
997 test('[Example 6.29]', () {
998 expectYamlLoads({
999 "First occurrence": "Value",
1000 "Second occurrence": "Value"
1001 },
1002 """
1003 First occurrence: &anchor Value
1004 Second occurrence: *anchor""");
1005 });
1006 });
1007
1008 // Chapter 7: Flow Styles
1009 group('7.1: Alias Nodes', () {
1010 test("must not use an anchor that doesn't previously occur", () {
1011 expectYamlFails(
1012 """
1013 - *anchor
1014 - &anchor foo""");
1015 });
1016
1017 test("don't have to exist for a given anchor node", () {
1018 expectYamlLoads(["foo"], "- &anchor foo");
1019 });
1020
1021 group('must not specify', () {
1022 test('tag properties', () => expectYamlFails(
1023 """
1024 - &anchor foo
1025 - !str *anchor"""));
1026
1027 test('anchor properties', () => expectYamlFails(
1028 """
1029 - &anchor foo
1030 - &anchor2 *anchor"""));
1031
1032 test('content', () => expectYamlFails(
1033 """
1034 - &anchor foo
1035 - *anchor bar"""));
1036 });
1037
1038 test('must preserve structural equality', () {
1039 var doc = loadYaml(cleanUpLiteral(
1040 """
1041 anchor: &anchor [a, b, c]
1042 alias: *anchor"""));
1043 var anchorList = doc['anchor'];
1044 var aliasList = doc['alias'];
1045 expect(anchorList, same(aliasList));
1046
1047 doc = loadYaml(cleanUpLiteral(
1048 """
1049 ? &anchor [a, b, c]
1050 : ? *anchor
1051 : bar"""));
1052 anchorList = doc.keys.first;
1053 aliasList = doc[['a', 'b', 'c']].keys.first;
1054 expect(anchorList, same(aliasList));
1055 });
1056
1057 test('[Example 7.1]', () {
1058 expectYamlLoads({
1059 "First occurrence": "Foo",
1060 "Second occurrence": "Foo",
1061 "Override anchor": "Bar",
1062 "Reuse anchor": "Bar",
1063 },
1064 """
1065 First occurrence: &anchor Foo
1066 Second occurrence: *anchor
1067 Override anchor: &anchor Bar
1068 Reuse anchor: *anchor""");
1069 });
1070 });
1071
1072 group('7.2: Empty Nodes', () {
1073 test('[Example 7.2]', () {
1074 expectYamlLoads({
1075 "foo": "",
1076 "": "bar"
1077 },
1078 """
1079 {
1080 foo : !!str,
1081 !!str : bar,
1082 }""");
1083 });
1084
1085 test('[Example 7.3]', () {
1086 var doc = deepEqualsMap({"foo": null});
1087 doc[null] = "bar";
1088 expectYamlLoads(doc,
1089 """
1090 {
1091 ? foo :,
1092 : bar,
1093 }""");
1094 });
1095 });
1096
1097 group('7.3: Flow Scalar Styles', () {
1098 test('[Example 7.4]', () {
1099 expectYamlLoads({
1100 "implicit block key": [{"implicit flow key": "value"}]
1101 },
1102 '''
1103 "implicit block key" : [
1104 "implicit flow key" : value,
1105 ]''');
1106 });
1107
1108 test('[Example 7.5]', () {
1109 expectYamlLoads(
1110 "folded to a space,\nto a line feed, or \t \tnon-content",
1111 '''
1112 "folded
1113 to a space,\t
1114
1115 to a line feed, or \t\\
1116 \\ \tnon-content"''');
1117 });
1118
1119 test('[Example 7.6]', () {
1120 expectYamlLoads(" 1st non-empty\n2nd non-empty 3rd non-empty ",
1121 '''
1122 " 1st non-empty
1123
1124 2nd non-empty
1125 \t3rd non-empty "''');
1126 });
1127
1128 test('[Example 7.7]', () {
1129 expectYamlLoads("here's to \"quotes\"", "'here''s to \"quotes\"'");
1130 });
1131
1132 test('[Example 7.8]', () {
1133 expectYamlLoads({
1134 "implicit block key": [{"implicit flow key": "value"}]
1135 },
1136 """
1137 'implicit block key' : [
1138 'implicit flow key' : value,
1139 ]""");
1140 });
1141
1142 test('[Example 7.9]', () {
1143 expectYamlLoads(" 1st non-empty\n2nd non-empty 3rd non-empty ",
1144 """
1145 ' 1st non-empty
1146
1147 2nd non-empty
1148 \t3rd non-empty '""");
1149 });
1150
1151 test('[Example 7.10]', () {
1152 expectYamlLoads([
1153 "::vector", ": - ()", "Up, up, and away!", -123,
1154 "http://example.com/foo#bar",
1155 [
1156 "::vector", ": - ()", "Up, up, and away!", -123,
1157 "http://example.com/foo#bar"
1158 ]
1159 ],
1160 '''
1161 # Outside flow collection:
1162 - ::vector
1163 - ": - ()"
1164 - Up, up, and away!
1165 - -123
1166 - http://example.com/foo#bar
1167 # Inside flow collection:
1168 - [ ::vector,
1169 ": - ()",
1170 "Up, up, and away!",
1171 -123,
1172 http://example.com/foo#bar ]''');
1173 });
1174
1175 test('[Example 7.11]', () {
1176 expectYamlLoads({
1177 "implicit block key": [{"implicit flow key": "value"}]
1178 },
1179 """
1180 implicit block key : [
1181 implicit flow key : value,
1182 ]""");
1183 });
1184
1185 test('[Example 7.12]', () {
1186 expectYamlLoads("1st non-empty\n2nd non-empty 3rd non-empty",
1187 """
1188 1st non-empty
1189
1190 2nd non-empty
1191 \t3rd non-empty""");
1192 });
1193 });
1194
1195 group('7.4: Flow Collection Styles', () {
1196 test('[Example 7.13]', () {
1197 expectYamlLoads([
1198 ['one', 'two'],
1199 ['three', 'four']
1200 ],
1201 """
1202 - [ one, two, ]
1203 - [three ,four]""");
1204 });
1205
1206 test('[Example 7.14]', () {
1207 expectYamlLoads([
1208 "double quoted", "single quoted", "plain text", ["nested"],
1209 {"single": "pair"}
1210 ],
1211 """
1212 [
1213 "double
1214 quoted", 'single
1215 quoted',
1216 plain
1217 text, [ nested ],
1218 single: pair,
1219 ]""");
1220 });
1221
1222 test('[Example 7.15]', () {
1223 expectYamlLoads([
1224 {"one": "two", "three": "four"},
1225 {"five": "six", "seven": "eight"},
1226 ],
1227 """
1228 - { one : two , three: four , }
1229 - {five: six,seven : eight}""");
1230 });
1231
1232 test('[Example 7.16]', () {
1233 var doc = deepEqualsMap({
1234 "explicit": "entry",
1235 "implicit": "entry"
1236 });
1237 doc[null] = null;
1238 expectYamlLoads(doc,
1239 """
1240 {
1241 ? explicit: entry,
1242 implicit: entry,
1243 ?
1244 }""");
1245 });
1246
1247 test('[Example 7.17]', () {
1248 var doc = deepEqualsMap({
1249 "unquoted": "separate",
1250 "http://foo.com": null,
1251 "omitted value": null
1252 });
1253 doc[null] = "omitted key";
1254 expectYamlLoads(doc,
1255 '''
1256 {
1257 unquoted : "separate",
1258 http://foo.com,
1259 omitted value:,
1260 : omitted key,
1261 }''');
1262 });
1263
1264 test('[Example 7.18]', () {
1265 expectYamlLoads({
1266 "adjacent": "value",
1267 "readable": "value",
1268 "empty": null
1269 },
1270 '''
1271 {
1272 "adjacent":value,
1273 "readable": value,
1274 "empty":
1275 }''');
1276 });
1277
1278 test('[Example 7.19]', () {
1279 expectYamlLoads([{"foo": "bar"}],
1280 """
1281 [
1282 foo: bar
1283 ]""");
1284 });
1285
1286 test('[Example 7.20]', () {
1287 expectYamlLoads([{"foo bar": "baz"}],
1288 """
1289 [
1290 ? foo
1291 bar : baz
1292 ]""");
1293 });
1294
1295 test('[Example 7.21]', () {
1296 var el1 = deepEqualsMap();
1297 el1[null] = "empty key entry";
1298
1299 var el2 = deepEqualsMap();
1300 el2[{"JSON": "like"}] = "adjacent";
1301
1302 expectYamlLoads([[{"YAML": "separate"}], [el1], [el2]],
1303 """
1304 - [ YAML : separate ]
1305 - [ : empty key entry ]
1306 - [ {JSON: like}:adjacent ]""");
1307 });
1308
1309 // TODO(nweiz): enable this when we throw an error for long or multiline
1310 // keys.
1311 // test('[Example 7.22]', () {
1312 // expectYamlFails(
1313 // """
1314 // [ foo
1315 // bar: invalid ]""");
1316 //
1317 // var dotList = new List.filled(1024, ' ');
1318 // var dots = dotList.join();
1319 // expectYamlFails('[ "foo...$dots...bar": invalid ]');
1320 // });
1321 });
1322
1323 group('7.5: Flow Nodes', () {
1324 test('[Example 7.23]', () {
1325 expectYamlLoads([["a", "b"], {"a": "b"}, "a", "b", "c"],
1326 """
1327 - [ a, b ]
1328 - { a: b }
1329 - "a"
1330 - 'b'
1331 - c""");
1332 });
1333
1334 test('[Example 7.24]', () {
1335 expectYamlLoads(["a", "b", "c", "c", ""],
1336 """
1337 - !!str "a"
1338 - 'b'
1339 - &anchor "c"
1340 - *anchor
1341 - !!str""");
1342 });
1343 });
1344
1345 // Chapter 8: Block Styles
1346 group('8.1: Block Scalar Styles', () {
1347 test('[Example 8.1]', () {
1348 expectYamlLoads(["literal\n", " folded\n", "keep\n\n", " strip"],
1349 """
1350 - | # Empty header
1351 literal
1352 - >1 # Indentation indicator
1353 folded
1354 - |+ # Chomping indicator
1355 keep
1356
1357 - >1- # Both indicators
1358 strip""");
1359 });
1360
1361 test('[Example 8.2]', () {
1362 // Note: in the spec, the fourth element in this array is listed as
1363 // "\t detected\n", not "\t\ndetected\n". However, I'm reasonably
1364 // confident that "\t\ndetected\n" is correct when parsed according to the
1365 // rest of the spec.
1366 expectYamlLoads([
1367 "detected\n",
1368 "\n\n# detected\n",
1369 " explicit\n",
1370 "\t\ndetected\n"
1371 ],
1372 """
1373 - |
1374 detected
1375 - >
1376
1377
1378 # detected
1379 - |1
1380 explicit
1381 - >
1382 \t
1383 detected
1384 """);
1385 });
1386
1387 test('[Example 8.3]', () {
1388 expectYamlFails(
1389 """
1390 - |
1391
1392 text""");
1393
1394 expectYamlFails(
1395 """
1396 - >
1397 text
1398 text""");
1399
1400 expectYamlFails(
1401 """
1402 - |2
1403 text""");
1404 });
1405
1406 test('[Example 8.4]', () {
1407 expectYamlLoads({"strip": "text", "clip": "text\n", "keep": "text\n"},
1408 """
1409 strip: |-
1410 text
1411 clip: |
1412 text
1413 keep: |+
1414 text
1415 """);
1416 });
1417
1418 test('[Example 8.5]', () {
1419 // This example in the spec only includes a single newline in the "keep"
1420 // value, but as far as I can tell that's not how it's supposed to be
1421 // parsed according to the rest of the spec.
1422 expectYamlLoads({
1423 "strip": "# text",
1424 "clip": "# text\n",
1425 "keep": "# text\n\n"
1426 },
1427 """
1428 # Strip
1429 # Comments:
1430 strip: |-
1431 # text
1432
1433 # Clip
1434 # comments:
1435
1436 clip: |
1437 # text
1438
1439 # Keep
1440 # comments:
1441
1442 keep: |+
1443 # text
1444
1445 # Trail
1446 # comments.
1447 """);
1448 });
1449
1450 test('[Example 8.6]', () {
1451 expectYamlLoads({"strip": "", "clip": "", "keep": "\n"},
1452 """
1453 strip: >-
1454
1455 clip: >
1456
1457 keep: |+
1458
1459 """);
1460 });
1461
1462 test('[Example 8.7]', () {
1463 expectYamlLoads("literal\n\ttext\n",
1464 """
1465 |
1466 literal
1467 \ttext
1468 """);
1469 });
1470
1471 test('[Example 8.8]', () {
1472 expectYamlLoads("\n\nliteral\n \n\ntext\n",
1473 """
1474 |
1475
1476
1477 literal
1478
1479
1480 text
1481
1482 # Comment""");
1483 });
1484
1485 test('[Example 8.9]', () {
1486 expectYamlLoads("folded text\n",
1487 """
1488 >
1489 folded
1490 text
1491 """);
1492 });
1493
1494 test('[Example 8.10]', () {
1495 expectYamlLoads(
1496 cleanUpLiteral("""
1497
1498 folded line
1499 next line
1500 * bullet
1501
1502 * list
1503 * lines
1504
1505 last line
1506 """),
1507 """
1508 >
1509
1510 folded
1511 line
1512
1513 next
1514 line
1515 * bullet
1516
1517 * list
1518 * lines
1519
1520 last
1521 line
1522
1523 # Comment""");
1524 });
1525
1526 // Examples 8.11 through 8.13 are duplicates of 8.10.
1527 });
1528
1529 group('8.2: Block Collection Styles', () {
1530 test('[Example 8.14]', () {
1531 expectYamlLoads({"block sequence": ["one", {"two": "three"}]},
1532 """
1533 block sequence:
1534 - one
1535 - two : three""");
1536 });
1537
1538 test('[Example 8.15]', () {
1539 expectYamlLoads([
1540 null, "block node\n", ["one", "two"], {"one": "two"}
1541 ],
1542 """
1543 - # Empty
1544 - |
1545 block node
1546 - - one # Compact
1547 - two # sequence
1548 - one: two # Compact mapping""");
1549 });
1550
1551 test('[Example 8.16]', () {
1552 expectYamlLoads({"block mapping": {"key": "value"}},
1553 """
1554 block mapping:
1555 key: value""");
1556 });
1557
1558 test('[Example 8.17]', () {
1559 expectYamlLoads({
1560 "explicit key": null,
1561 "block key\n": ["one", "two"]
1562 },
1563 """
1564 ? explicit key # Empty value
1565 ? |
1566 block key
1567 : - one # Explicit compact
1568 - two # block value""");
1569 });
1570
1571 test('[Example 8.18]', () {
1572 var doc = deepEqualsMap({
1573 'plain key': 'in-line value',
1574 "quoted key": ["entry"]
1575 });
1576 doc[null] = null;
1577 expectYamlLoads(doc,
1578 '''
1579 plain key: in-line value
1580 : # Both empty
1581 "quoted key":
1582 - entry''');
1583 });
1584
1585 test('[Example 8.19]', () {
1586 var el = deepEqualsMap();
1587 el[{'earth': 'blue'}] = {'moon': 'white'};
1588 expectYamlLoads([{'sun': 'yellow'}, el],
1589 """
1590 - sun: yellow
1591 - ? earth: blue
1592 : moon: white""");
1593 });
1594
1595 test('[Example 8.20]', () {
1596 expectYamlLoads(["flow in block", "Block scalar\n", {"foo": "bar"}],
1597 '''
1598 -
1599 "flow in block"
1600 - >
1601 Block scalar
1602 - !!map # Block collection
1603 foo : bar''');
1604 });
1605
1606 test('[Example 8.21]', () {
1607 // The spec doesn't include a newline after "value" in the parsed map, but
1608 // the block scalar is clipped so it should be retained.
1609 expectYamlLoads({"literal": "value\n", "folded": "value"},
1610 """
1611 literal: |2
1612 value
1613 folded:
1614 !!str
1615 >1
1616 value""");
1617 });
1618
1619 test('[Example 8.22]', () {
1620 expectYamlLoads({
1621 "sequence": ["entry", ["nested"]],
1622 "mapping": {"foo": "bar"}
1623 },
1624 """
1625 sequence: !!seq
1626 - entry
1627 - !!seq
1628 - nested
1629 mapping: !!map
1630 foo: bar""");
1631 });
1632 });
1633
1634 // Chapter 9: YAML Character Stream
1635 group('9.1: Documents', () {
1636 // Example 9.1 tests the use of a BOM, which this implementation currently
1637 // doesn't plan to support.
1638
1639 test('[Example 9.2]', () {
1640 expectYamlLoads("Document",
1641 """
1642 %YAML 1.2
1643 ---
1644 Document
1645 ... # Suffix""");
1646 });
1647
1648 test('[Example 9.3]', () {
1649 // The spec example indicates that the comment after "%!PS-Adobe-2.0"
1650 // should be stripped, which would imply that that line is not part of the
1651 // literal defined by the "|". The rest of the spec is ambiguous on this
1652 // point; the allowable indentation for non-indented literal content is
1653 // not clearly explained. However, if both the "|" and the text were
1654 // indented the same amount, the text would be part of the literal, which
1655 // implies that the spec's parse of this document is incorrect.
1656 expectYamlStreamLoads(
1657 ["Bare document", "%!PS-Adobe-2.0 # Not the first line\n"],
1658 """
1659 Bare
1660 document
1661 ...
1662 # No document
1663 ...
1664 |
1665 %!PS-Adobe-2.0 # Not the first line
1666 """);
1667 });
1668
1669 test('[Example 9.4]', () {
1670 expectYamlStreamLoads([{"matches %": 20}, null],
1671 """
1672 ---
1673 { matches
1674 % : 20 }
1675 ...
1676 ---
1677 # Empty
1678 ...""");
1679 });
1680
1681 test('[Example 9.5]', () {
1682 // The spec doesn't have a space between the second
1683 // "YAML" and "1.2", but this seems to be a typo.
1684 expectYamlStreamLoads(["%!PS-Adobe-2.0\n", null],
1685 """
1686 %YAML 1.2
1687 --- |
1688 %!PS-Adobe-2.0
1689 ...
1690 %YAML 1.2
1691 ---
1692 # Empty
1693 ...""");
1694 });
1695
1696 test('[Example 9.6]', () {
1697 expectYamlStreamLoads(["Document", null, {"matches %": 20}],
1698 """
1699 Document
1700 ---
1701 # Empty
1702 ...
1703 %YAML 1.2
1704 ---
1705 matches %: 20""");
1706 });
1707 });
1708
1709 // Chapter 10: Recommended Schemas
1710 group('10.1: Failsafe Schema', () {
1711 test('[Example 10.1]', () {
1712 expectYamlLoads({
1713 "Block style": {
1714 "Clark": "Evans",
1715 "Ingy": "döt Net",
1716 "Oren": "Ben-Kiki"
1717 },
1718 "Flow style": {
1719 "Clark": "Evans",
1720 "Ingy": "döt Net",
1721 "Oren": "Ben-Kiki"
1722 }
1723 },
1724 """
1725 Block style: !!map
1726 Clark : Evans
1727 Ingy : döt Net
1728 Oren : Ben-Kiki
1729
1730 Flow style: !!map { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki }""");
1731 });
1732
1733 test('[Example 10.2]', () {
1734 expectYamlLoads({
1735 "Block style": ["Clark Evans", "Ingy döt Net", "Oren Ben-Kiki"],
1736 "Flow style": ["Clark Evans", "Ingy döt Net", "Oren Ben-Kiki"]
1737 },
1738 """
1739 Block style: !!seq
1740 - Clark Evans
1741 - Ingy döt Net
1742 - Oren Ben-Kiki
1743
1744 Flow style: !!seq [ Clark Evans, Ingy döt Net, Oren Ben-Kiki ]""");
1745 });
1746
1747 test('[Example 10.3]', () {
1748 expectYamlLoads({
1749 "Block style": "String: just a theory.",
1750 "Flow style": "String: just a theory."
1751 },
1752 '''
1753 Block style: !!str |-
1754 String: just a theory.
1755
1756 Flow style: !!str "String: just a theory."''');
1757 });
1758 });
1759
1760 group('10.2: JSON Schema', () {
1761 // test('[Example 10.4]', () {
1762 // var doc = deepEqualsMap({"key with null value": null});
1763 // doc[null] = "value for null key";
1764 // expectYamlStreamLoads(doc,
1765 // """
1766 // !!null null: value for null key
1767 // key with null value: !!null null""");
1768 // });
1769
1770 // test('[Example 10.5]', () {
1771 // expectYamlStreamLoads({
1772 // "YAML is a superset of JSON": true,
1773 // "Pluto is a planet": false
1774 // },
1775 // """
1776 // YAML is a superset of JSON: !!bool true
1777 // Pluto is a planet: !!bool false""");
1778 // });
1779
1780 // test('[Example 10.6]', () {
1781 // expectYamlStreamLoads({
1782 // "negative": -12,
1783 // "zero": 0,
1784 // "positive": 34
1785 // },
1786 // """
1787 // negative: !!int -12
1788 // zero: !!int 0
1789 // positive: !!int 34""");
1790 // });
1791
1792 // test('[Example 10.7]', () {
1793 // expectYamlStreamLoads({
1794 // "negative": -1,
1795 // "zero": 0,
1796 // "positive": 23000,
1797 // "infinity": infinity,
1798 // "not a number": nan
1799 // },
1800 // """
1801 // negative: !!float -1
1802 // zero: !!float 0
1803 // positive: !!float 2.3e4
1804 // infinity: !!float .inf
1805 // not a number: !!float .nan""");
1806 // });
1807
1808 // test('[Example 10.8]', () {
1809 // expectYamlStreamLoads({
1810 // "A null": null,
1811 // "Booleans": [true, false],
1812 // "Integers": [0, -0, 3, -19],
1813 // "Floats": [0, 0, 12000, -200000],
1814 // // Despite being invalid in the JSON schema, these values are valid i n
1815 // // the core schema which this implementation supports.
1816 // "Invalid": [ true, null, 7, 0x3A, 12.3]
1817 // },
1818 // """
1819 // A null: null
1820 // Booleans: [ true, false ]
1821 // Integers: [ 0, -0, 3, -19 ]
1822 // Floats: [ 0., -0.0, 12e03, -2E+05 ]
1823 // Invalid: [ True, Null, 0o7, 0x3A, +12.3 ]""");
1824 // });
1825 });
1826
1827 group('10.3: Core Schema', () {
1828 test('[Example 10.9]', () {
1829 expectYamlLoads({
1830 "A null": null,
1831 "Also a null": null,
1832 "Not a null": "",
1833 "Booleans": [true, true, false, false],
1834 "Integers": [0, 7, 0x3A, -19],
1835 "Floats": [0, 0, 0.5, 12000, -200000],
1836 "Also floats": [infinity, -infinity, infinity, nan]
1837 },
1838 '''
1839 A null: null
1840 Also a null: # Empty
1841 Not a null: ""
1842 Booleans: [ true, True, false, FALSE ]
1843 Integers: [ 0, 0o7, 0x3A, -19 ]
1844 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ]
1845 Also floats: [ .inf, -.Inf, +.INF, .NAN ]''');
1846 });
1847 });
1848 }
OLDNEW
« no previous file with comments | « mojo/public/dart/third_party/yaml/test/yaml_node_wrapper_test.dart ('k') | mojo/public/tools/dart_pkg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698