OLD | NEW |
---|---|
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 // TODO(rnystrom): rewrite tests so that they don't need "Expect". | 7 // TODO(rnystrom): rewrite tests so that they don't need "Expect". |
8 import "package:expect/expect.dart"; | |
9 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
10 import 'package:yaml/yaml.dart'; | 9 import 'package:yaml/yaml.dart'; |
11 import 'package:yaml/src/deep_equals.dart'; | |
12 // TODO(jmesserly): we should not be reaching outside the YAML package | |
13 // The http package has a similar problem. | |
14 import '../../../tests/utils/test_utils.dart'; | |
15 | 10 |
16 /// Constructs a new yaml.YamlMap, optionally from a normal Map. | 11 import 'utils.dart'; |
Bob Nystrom
2014/05/09 00:18:56
Is this a new file? I don't see it in the patch.
nweiz
2014/05/20 00:15:07
Oops, added.
| |
17 Map yamlMap([Map from]) => | |
18 from == null ? new YamlMap() : new YamlMap.from(from); | |
19 | |
20 /// Asserts that a string containing a single YAML document produces a given | |
21 /// value when loaded. | |
22 expectYamlLoads(expected, String source) { | |
23 var actual = loadYaml(cleanUpLiteral(source)); | |
24 Expect.isTrue(deepEquals(expected, actual), | |
25 'expectYamlLoads(expected: <$expected>, actual: <$actual>)'); | |
26 } | |
27 | |
28 /// Asserts that a string containing a stream of YAML documents produces a given | |
29 /// list of values when loaded. | |
30 expectYamlStreamLoads(List expected, String source) { | |
31 var actual = loadYamlStream(cleanUpLiteral(source)); | |
32 Expect.isTrue(deepEquals(expected, actual), | |
33 'expectYamlStreamLoads(expected: <$expected>, actual: <$actual>)'); | |
34 } | |
35 | 12 |
36 main() { | 13 main() { |
37 var infinity = double.parse("Infinity"); | 14 var infinity = double.parse("Infinity"); |
38 var nan = double.parse("NaN"); | 15 var nan = double.parse("NaN"); |
39 | 16 |
40 group('YamlMap', () { | 17 group('YamlMap', () { |
41 group('accepts as a key', () { | 18 group('accepts as a key', () { |
42 _expectKeyWorks(keyFn()) { | 19 _expectKeyWorks(keyFn()) { |
43 var map = yamlMap(); | 20 var map = yamlMap(); |
44 map[keyFn()] = 5; | 21 map[keyFn()] = 5; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 } | 470 } |
494 | 471 |
495 expectAllowsQuotedCharacter(int charCode) { | 472 expectAllowsQuotedCharacter(int charCode) { |
496 var char = new String.fromCharCodes([charCode]); | 473 var char = new String.fromCharCodes([charCode]); |
497 expectYamlLoads("The character '$char' is allowed", | 474 expectYamlLoads("The character '$char' is allowed", |
498 '"The character \'$char\' is allowed"'); | 475 '"The character \'$char\' is allowed"'); |
499 } | 476 } |
500 | 477 |
501 expectDisallowsCharacter(int charCode) { | 478 expectDisallowsCharacter(int charCode) { |
502 var char = new String.fromCharCodes([charCode]); | 479 var char = new String.fromCharCodes([charCode]); |
503 Expect.throws(() => loadYaml('The character "$char" is disallowed')); | 480 expectYamlFails('The character "$char" is disallowed'); |
504 } | 481 } |
505 | 482 |
506 test("doesn't include C0 control characters", () { | 483 test("doesn't include C0 control characters", () { |
507 expectDisallowsCharacter(0x0); | 484 expectDisallowsCharacter(0x0); |
508 expectDisallowsCharacter(0x8); | 485 expectDisallowsCharacter(0x8); |
509 expectDisallowsCharacter(0x1F); | 486 expectDisallowsCharacter(0x1F); |
510 }); | 487 }); |
511 | 488 |
512 test("includes TAB", () => expectAllowsCharacter(0x9)); | 489 test("includes TAB", () => expectAllowsCharacter(0x9)); |
513 test("doesn't include DEL", () => expectDisallowsCharacter(0x7F)); | 490 test("doesn't include DEL", () => expectDisallowsCharacter(0x7F)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 }); | 568 }); |
592 | 569 |
593 // test('[Example 5.9]', () { | 570 // test('[Example 5.9]', () { |
594 // expectYamlLoads("text", | 571 // expectYamlLoads("text", |
595 // """ | 572 // """ |
596 // %YAML 1.2 | 573 // %YAML 1.2 |
597 // --- text"""); | 574 // --- text"""); |
598 // }); | 575 // }); |
599 | 576 |
600 test('[Example 5.10]', () { | 577 test('[Example 5.10]', () { |
601 Expect.throws(() => loadYaml("commercial-at: @text")); | 578 expectYamlFails("commercial-at: @text"); |
602 Expect.throws(() => loadYaml("commercial-at: `text")); | 579 expectYamlFails("commercial-at: `text"); |
603 }); | 580 }); |
604 }); | 581 }); |
605 | 582 |
606 group('5.4: Line Break Characters', () { | 583 group('5.4: Line Break Characters', () { |
607 group('include', () { | 584 group('include', () { |
608 test('\\n', () => expectYamlLoads([1, 2], indentLiteral("- 1\n- 2"))); | 585 test('\\n', () => expectYamlLoads([1, 2], indentLiteral("- 1\n- 2"))); |
609 test('\\r', () => expectYamlLoads([1, 2], "- 1\r- 2")); | 586 test('\\r', () => expectYamlLoads([1, 2], "- 1\r- 2")); |
610 }); | 587 }); |
611 | 588 |
612 group('do not include', () { | 589 group('do not include', () { |
613 test('form feed', () => Expect.throws(() => loadYaml("- 1\x0C- 2"))); | 590 test('form feed', () => expectYamlFails("- 1\x0C- 2")); |
614 test('NEL', () => expectYamlLoads(["1\x85- 2"], "- 1\x85- 2")); | 591 test('NEL', () => expectYamlLoads(["1\x85- 2"], "- 1\x85- 2")); |
615 test('0x2028', () => expectYamlLoads(["1\u2028- 2"], "- 1\u2028- 2")); | 592 test('0x2028', () => expectYamlLoads(["1\u2028- 2"], "- 1\u2028- 2")); |
616 test('0x2029', () => expectYamlLoads(["1\u2029- 2"], "- 1\u2029- 2")); | 593 test('0x2029', () => expectYamlLoads(["1\u2029- 2"], "- 1\u2029- 2")); |
617 }); | 594 }); |
618 | 595 |
619 group('in a scalar context must be normalized', () { | 596 group('in a scalar context must be normalized', () { |
620 test("from \\r to \\n", () => | 597 test("from \\r to \\n", () => |
621 expectYamlLoads(["foo\nbar"], indentLiteral('- |\n foo\r bar'))); | 598 expectYamlLoads(["foo\nbar"], indentLiteral('- |\n foo\r bar'))); |
622 test("from \\r\\n to \\n", () => | 599 test("from \\r\\n to \\n", () => |
623 expectYamlLoads(["foo\nbar"], indentLiteral('- |\n foo\r\n bar'))) ; | 600 expectYamlLoads(["foo\nbar"], indentLiteral('- |\n foo\r\n bar'))) ; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 "A A A", | 639 "A A A", |
663 ''' | 640 ''' |
664 "Fun with \\\\ | 641 "Fun with \\\\ |
665 \\" \\a \\b \\e \\f \\ | 642 \\" \\a \\b \\e \\f \\ |
666 \\n \\r \\t \\v \\0 \\ | 643 \\n \\r \\t \\v \\0 \\ |
667 \\ \\_ \\N \\L \\P \\ | 644 \\ \\_ \\N \\L \\P \\ |
668 \\x41 \\u0041 \\U00000041"'''); | 645 \\x41 \\u0041 \\U00000041"'''); |
669 }); | 646 }); |
670 | 647 |
671 test('[Example 5.14]', () { | 648 test('[Example 5.14]', () { |
672 Expect.throws(() => loadYaml('Bad escape: "\\c"')); | 649 expectYamlFails('Bad escape: "\\c"'); |
673 Expect.throws(() => loadYaml('Bad escape: "\\xq-"')); | 650 expectYamlFails('Bad escape: "\\xq-"'); |
674 }); | 651 }); |
675 }); | 652 }); |
676 | 653 |
677 // Chapter 6: Basic Structures | 654 // Chapter 6: Basic Structures |
678 group('6.1: Indentation Spaces', () { | 655 group('6.1: Indentation Spaces', () { |
679 test('may not include TAB characters', () { | 656 test('may not include TAB characters', () { |
680 Expect.throws(() => loadYaml(cleanUpLiteral( | 657 expectYamlFails( |
681 """ | 658 """ |
682 - | 659 - |
683 \t- foo | 660 \t- foo |
684 \t- bar"""))); | 661 \t- bar"""); |
685 }); | 662 }); |
686 | 663 |
687 test('must be the same for all sibling nodes', () { | 664 test('must be the same for all sibling nodes', () { |
688 Expect.throws(() => loadYaml(cleanUpLiteral( | 665 expectYamlFails( |
689 """ | 666 """ |
690 - | 667 - |
691 - foo | 668 - foo |
692 - bar"""))); | 669 - bar"""); |
693 }); | 670 }); |
694 | 671 |
695 test('may be different for the children of sibling nodes', () { | 672 test('may be different for the children of sibling nodes', () { |
696 expectYamlLoads([["foo"], ["bar"]], | 673 expectYamlLoads([["foo"], ["bar"]], |
697 """ | 674 """ |
698 - | 675 - |
699 - foo | 676 - foo |
700 - | 677 - |
701 - bar"""); | 678 - bar"""); |
702 }); | 679 }); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 - | # comment | 886 - | # comment |
910 # not comment | 887 # not comment |
911 foo | 888 foo |
912 """); | 889 """); |
913 }); | 890 }); |
914 }); | 891 }); |
915 }); | 892 }); |
916 | 893 |
917 group('6.7: Separation Lines', () { | 894 group('6.7: Separation Lines', () { |
918 test('may not be used within implicit keys', () { | 895 test('may not be used within implicit keys', () { |
919 Expect.throws(() => loadYaml(cleanUpLiteral( | 896 expectYamlFails( |
920 """ | 897 """ |
921 [1, | 898 [1, |
922 2]: 3"""))); | 899 2]: 3"""); |
923 }); | 900 }); |
924 | 901 |
925 test('[Example 6.12]', () { | 902 test('[Example 6.12]', () { |
926 var doc = yamlMap(); | 903 var doc = yamlMap(); |
927 doc[{'first': 'Sammy', 'last': 'Sosa'}] = { | 904 doc[{'first': 'Sammy', 'last': 'Sosa'}] = { |
928 'hr': 65, | 905 'hr': 65, |
929 'avg': 0.278 | 906 'avg': 0.278 |
930 }; | 907 }; |
931 expectYamlLoads(doc, | 908 expectYamlLoads(doc, |
932 """ | 909 """ |
(...skipping 20 matching lines...) Expand all Loading... | |
953 // test('[Example 6.14]', () { | 930 // test('[Example 6.14]', () { |
954 // expectYamlLoads("foo", | 931 // expectYamlLoads("foo", |
955 // ''' | 932 // ''' |
956 // %YAML 1.3 # Attempt parsing | 933 // %YAML 1.3 # Attempt parsing |
957 // # with a warning | 934 // # with a warning |
958 // --- | 935 // --- |
959 // "foo"'''); | 936 // "foo"'''); |
960 // }); | 937 // }); |
961 | 938 |
962 // test('[Example 6.15]', () { | 939 // test('[Example 6.15]', () { |
963 // Expect.throws(() => loadYaml(cleanUpLiteral( | 940 // expectYamlFails( |
964 // """ | 941 // """ |
965 // %YAML 1.2 | 942 // %YAML 1.2 |
966 // %YAML 1.1 | 943 // %YAML 1.1 |
967 // foo"""))); | 944 // foo"""); |
968 // }); | 945 // }); |
969 | 946 |
970 // test('[Example 6.16]', () { | 947 // test('[Example 6.16]', () { |
971 // expectYamlLoads("foo", | 948 // expectYamlLoads("foo", |
972 // ''' | 949 // ''' |
973 // %TAG !yaml! tag:yaml.org,2002: | 950 // %TAG !yaml! tag:yaml.org,2002: |
974 // --- | 951 // --- |
975 // !yaml!str "foo"'''); | 952 // !yaml!str "foo"'''); |
976 // }); | 953 // }); |
977 | 954 |
978 // test('[Example 6.17]', () { | 955 // test('[Example 6.17]', () { |
979 // Expect.throws(() => loadYaml(cleanUpLiteral( | 956 // ExpectYamlFails( |
980 // """ | 957 // """ |
981 // %TAG ! !foo | 958 // %TAG ! !foo |
982 // %TAG ! !foo | 959 // %TAG ! !foo |
983 // bar"""))); | 960 // bar"""); |
984 // }); | 961 // }); |
985 | 962 |
986 // Examples 6.18 through 6.22 test custom tag URIs, which this | 963 // Examples 6.18 through 6.22 test custom tag URIs, which this |
987 // implementation currently doesn't plan to support. | 964 // implementation currently doesn't plan to support. |
988 }); | 965 }); |
989 | 966 |
990 group('6.9: Node Properties', () { | 967 group('6.9: Node Properties', () { |
991 // test('may be specified in any order', () { | 968 // test('may be specified in any order', () { |
992 // expectYamlLoads(["foo", "bar"], | 969 // expectYamlLoads(["foo", "bar"], |
993 // """ | 970 // """ |
994 // - !!str &a1 foo | 971 // - !!str &a1 foo |
995 // - &a2 !!str bar"""); | 972 // - &a2 !!str bar"""); |
996 // }); | 973 // }); |
997 | 974 |
998 // test('[Example 6.23]', () { | 975 // test('[Example 6.23]', () { |
999 // expectYamlLoads({ | 976 // expectYamlLoads({ |
1000 // "foo": "bar", | 977 // "foo": "bar", |
1001 // "baz": "foo" | 978 // "baz": "foo" |
1002 // }, | 979 // }, |
1003 // ''' | 980 // ''' |
1004 // !!str &a1 "foo": | 981 // !!str &a1 "foo": |
1005 // !!str bar | 982 // !!str bar |
1006 // &a2 baz : *a1'''); | 983 // &a2 baz : *a1'''); |
1007 // }); | 984 // }); |
1008 | 985 |
1009 // // Example 6.24 tests custom tag URIs, which this implementation currentl y | 986 // // Example 6.24 tests custom tag URIs, which this implementation currentl y |
1010 // // doesn't plan to support. | 987 // // doesn't plan to support. |
1011 | 988 |
1012 // test('[Example 6.25]', () { | 989 // test('[Example 6.25]', () { |
1013 // Expect.throws(() => loadYaml("- !<!> foo")); | 990 // expectYamlFails("- !<!> foo"); |
1014 // Expect.throws(() => loadYaml("- !<\$:?> foo")); | 991 // expectYamlFails("- !<\$:?> foo"); |
1015 // }); | 992 // }); |
1016 | 993 |
1017 // // Examples 6.26 and 6.27 test custom tag URIs, which this implementation | 994 // // Examples 6.26 and 6.27 test custom tag URIs, which this implementation |
1018 // // currently doesn't plan to support. | 995 // // currently doesn't plan to support. |
1019 | 996 |
1020 // test('[Example 6.28]', () { | 997 // test('[Example 6.28]', () { |
1021 // expectYamlLoads(["12", 12, "12"], | 998 // expectYamlLoads(["12", 12, "12"], |
1022 // ''' | 999 // ''' |
1023 // # Assuming conventional resolution: | 1000 // # Assuming conventional resolution: |
1024 // - "12" | 1001 // - "12" |
1025 // - 12 | 1002 // - 12 |
1026 // - ! 12'''); | 1003 // - ! 12'''); |
1027 // }); | 1004 // }); |
1028 | 1005 |
1029 // test('[Example 6.29]', () { | 1006 // test('[Example 6.29]', () { |
1030 // expectYamlLoads({ | 1007 // expectYamlLoads({ |
1031 // "First occurrence": "Value", | 1008 // "First occurrence": "Value", |
1032 // "Second occurrence": "anchor" | 1009 // "Second occurrence": "anchor" |
1033 // }, | 1010 // }, |
1034 // """ | 1011 // """ |
1035 // First occurrence: &anchor Value | 1012 // First occurrence: &anchor Value |
1036 // Second occurrence: *anchor"""); | 1013 // Second occurrence: *anchor"""); |
1037 // }); | 1014 // }); |
1038 }); | 1015 }); |
1039 | 1016 |
1040 // Chapter 7: Flow Styles | 1017 // Chapter 7: Flow Styles |
1041 group('7.1: Alias Nodes', () { | 1018 group('7.1: Alias Nodes', () { |
1042 // test("must not use an anchor that doesn't previously occur", () { | 1019 // test("must not use an anchor that doesn't previously occur", () { |
1043 // Expect.throws(() => loadYaml(cleanUpLiteral( | 1020 // expectYamlFails( |
1044 // """ | 1021 // """ |
1045 // - *anchor | 1022 // - *anchor |
1046 // - &anchor foo""")); | 1023 // - &anchor foo"""); |
1047 // }); | 1024 // }); |
1048 | 1025 |
1049 // test("don't have to exist for a given anchor node", () { | 1026 // test("don't have to exist for a given anchor node", () { |
1050 // expectYamlLoads(["foo"], "- &anchor foo"); | 1027 // expectYamlLoads(["foo"], "- &anchor foo"); |
1051 // }); | 1028 // }); |
1052 | 1029 |
1053 // group('must not specify', () { | 1030 // group('must not specify', () { |
1054 // test('tag properties', () => Expect.throws(() => loadYaml(cleanUpLitera l( | 1031 // test('tag properties', () => expectYamlFails( |
1055 // """ | 1032 // """ |
1056 // - &anchor foo | 1033 // - &anchor foo |
1057 // - !str *anchor"""))); | 1034 // - !str *anchor"""); |
1058 | 1035 |
1059 // test('anchor properties', () => Expect.throws( | 1036 // test('anchor properties', () => expectYamlFails( |
1060 // () => loadYaml(cleanUpLiteral( | |
1061 // """ | 1037 // """ |
1062 // - &anchor foo | 1038 // - &anchor foo |
1063 // - &anchor2 *anchor"""))); | 1039 // - &anchor2 *anchor"""); |
1064 | 1040 |
1065 // test('content', () => Expect.throws(() => loadYaml(cleanUpLiteral( | 1041 // test('content', () => expectYamlFails( |
1066 // """ | 1042 // """ |
1067 // - &anchor foo | 1043 // - &anchor foo |
1068 // - *anchor bar"""))); | 1044 // - *anchor bar"""))); |
1069 // }); | 1045 // }); |
1070 | 1046 |
1071 // test('must preserve structural equality', () { | 1047 // test('must preserve structural equality', () { |
1072 // var doc = loadYaml(cleanUpLiteral( | 1048 // var doc = loadYaml(cleanUpLiteral( |
1073 // """ | 1049 // """ |
1074 // anchor: &anchor [a, b, c] | 1050 // anchor: &anchor [a, b, c] |
1075 // alias: *anchor"""); | 1051 // alias: *anchor"""); |
1076 // var anchorList = doc['anchor']; | 1052 // var anchorList = doc['anchor']; |
1077 // var aliasList = doc['alias']; | 1053 // var aliasList = doc['alias']; |
1078 // Expect.isTrue(anchorList === aliasList); | 1054 // expect(anchorList, same(aliasList)); |
1079 // anchorList.add('d'); | |
1080 // Expect.listEquals(['a', 'b', 'c', 'd'], aliasList); | |
1081 | 1055 |
1082 // doc = loadYaml(cleanUpLiteral( | 1056 // doc = loadYaml(cleanUpLiteral( |
1083 // """ | 1057 // """ |
1084 // ? &anchor [a, b, c] | 1058 // ? &anchor [a, b, c] |
1085 // : ? *anchor | 1059 // : ? *anchor |
1086 // : bar"""); | 1060 // : bar"""); |
1087 // anchorList = doc.keys[0]; | 1061 // anchorList = doc.keys[0]; |
1088 // aliasList = doc[['a', 'b', 'c']].keys[0]; | 1062 // aliasList = doc[['a', 'b', 'c']].keys[0]; |
1089 // Expect.isTrue(anchorList === aliasList); | 1063 // expect(anchorList, same(aliasList)); |
1090 // anchorList.add('d'); | |
1091 // Expect.listEquals(['a', 'b', 'c', 'd'], aliasList); | |
1092 // }); | 1064 // }); |
1093 | 1065 |
1094 // test('[Example 7.1]', () { | 1066 // test('[Example 7.1]', () { |
1095 // expectYamlLoads({ | 1067 // expectYamlLoads({ |
1096 // "First occurence": "Foo", | 1068 // "First occurence": "Foo", |
1097 // "Second occurence": "Foo", | 1069 // "Second occurence": "Foo", |
1098 // "Override anchor": "Bar", | 1070 // "Override anchor": "Bar", |
1099 // "Reuse anchor": "Bar", | 1071 // "Reuse anchor": "Bar", |
1100 // }, | 1072 // }, |
1101 // """ | 1073 // """ |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1337 el2[{"JSON": "like"}] = "adjacent"; | 1309 el2[{"JSON": "like"}] = "adjacent"; |
1338 | 1310 |
1339 expectYamlLoads([[{"YAML": "separate"}], [el1], [el2]], | 1311 expectYamlLoads([[{"YAML": "separate"}], [el1], [el2]], |
1340 """ | 1312 """ |
1341 - [ YAML : separate ] | 1313 - [ YAML : separate ] |
1342 - [ : empty key entry ] | 1314 - [ : empty key entry ] |
1343 - [ {JSON: like}:adjacent ]"""); | 1315 - [ {JSON: like}:adjacent ]"""); |
1344 }); | 1316 }); |
1345 | 1317 |
1346 test('[Example 7.22]', () { | 1318 test('[Example 7.22]', () { |
1347 Expect.throws(() => loadYaml(cleanUpLiteral( | 1319 expectYamlFails( |
1348 """ | 1320 """ |
1349 [ foo | 1321 [ foo |
1350 bar: invalid ]"""))); | 1322 bar: invalid ]"""); |
1351 | 1323 |
1352 // TODO(nweiz): enable this when we throw an error for long keys | 1324 // TODO(nweiz): enable this when we throw an error for long keys |
1353 // var dotList = new List.filled(1024, ' '); | 1325 // var dotList = new List.filled(1024, ' '); |
1354 // var dots = dotList.join(); | 1326 // var dots = dotList.join(); |
1355 // Expect.throws(() => loadYaml('[ "foo...$dots...bar": invalid ]')); | 1327 // expectYamlFails('[ "foo...$dots...bar": invalid ]'); |
1356 }); | 1328 }); |
1357 }); | 1329 }); |
1358 | 1330 |
1359 group('7.5: Flow Nodes', () { | 1331 group('7.5: Flow Nodes', () { |
1360 test('[Example 7.23]', () { | 1332 test('[Example 7.23]', () { |
1361 expectYamlLoads([["a", "b"], {"a": "b"}, "a", "b", "c"], | 1333 expectYamlLoads([["a", "b"], {"a": "b"}, "a", "b", "c"], |
1362 """ | 1334 """ |
1363 - [ a, b ] | 1335 - [ a, b ] |
1364 - { a: b } | 1336 - { a: b } |
1365 - "a" | 1337 - "a" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1414 # detected | 1386 # detected |
1415 - |1 | 1387 - |1 |
1416 explicit | 1388 explicit |
1417 - > | 1389 - > |
1418 \t | 1390 \t |
1419 detected | 1391 detected |
1420 """); | 1392 """); |
1421 }); | 1393 }); |
1422 | 1394 |
1423 test('[Example 8.3]', () { | 1395 test('[Example 8.3]', () { |
1424 Expect.throws(() => loadYaml(cleanUpLiteral( | 1396 expectYamlFails( |
1425 """ | 1397 """ |
1426 - | | 1398 - | |
1427 | 1399 |
1428 text"""))); | 1400 text"""); |
1429 | 1401 |
1430 Expect.throws(() => loadYaml(cleanUpLiteral( | 1402 expectYamlFails( |
1431 """ | 1403 """ |
1432 - > | 1404 - > |
1433 text | 1405 text |
1434 text"""))); | 1406 text"""); |
1435 | 1407 |
1436 Expect.throws(() => loadYaml(cleanUpLiteral( | 1408 expectYamlFails( |
1437 """ | 1409 """ |
1438 - |2 | 1410 - |2 |
1439 text"""))); | 1411 text"""); |
1440 }); | 1412 }); |
1441 | 1413 |
1442 test('[Example 8.4]', () { | 1414 test('[Example 8.4]', () { |
1443 expectYamlLoads({"strip": "text", "clip": "text\n", "keep": "text\n"}, | 1415 expectYamlLoads({"strip": "text", "clip": "text\n", "keep": "text\n"}, |
1444 """ | 1416 """ |
1445 strip: |- | 1417 strip: |- |
1446 text | 1418 text |
1447 clip: | | 1419 clip: | |
1448 text | 1420 text |
1449 keep: |+ | 1421 keep: |+ |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1871 A null: null | 1843 A null: null |
1872 Also a null: # Empty | 1844 Also a null: # Empty |
1873 Not a null: "" | 1845 Not a null: "" |
1874 Booleans: [ true, True, false, FALSE ] | 1846 Booleans: [ true, True, false, FALSE ] |
1875 Integers: [ 0, 0o7, 0x3A, -19 ] | 1847 Integers: [ 0, 0o7, 0x3A, -19 ] |
1876 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] | 1848 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] |
1877 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); | 1849 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); |
1878 }); | 1850 }); |
1879 }); | 1851 }); |
1880 } | 1852 } |
OLD | NEW |