File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## 3.1.4-wip
2+
13## 3.1.3
24
35* Require Dart 3.4
Original file line number Diff line number Diff line change 11name : yaml
2- version : 3.1.3
2+ version : 3.1.4-wip
33description : A parser for YAML, a human-friendly data serialization standard
44repository : https://github.com/dart-lang/tools/tree/main/pkgs/yaml
55issue_tracker : https://github.com/dart-lang/tools/labels/package%3Ayaml
Original file line number Diff line number Diff line change @@ -53,6 +53,23 @@ void expectYamlFails(String source) {
5353 expect (() => loadYaml (cleanUpLiteral (source)), throwsYamlException);
5454}
5555
56+ /// Asserts that a string containing a single YAML document produces a given
57+ /// value and emits warnings when loaded.
58+ void expectYamlLoadsWithWarning (
59+ Object ? expected, String source, String expectedWarning) {
60+ final warnings = < String > [];
61+ final oldCallback = yamlWarningCallback;
62+ yamlWarningCallback = (message, [_]) {
63+ warnings.add (message);
64+ };
65+ try {
66+ expectYamlLoads (expected, source);
67+ expect (warnings, ['Warning: $expectedWarning ' ]);
68+ } finally {
69+ yamlWarningCallback = oldCallback;
70+ }
71+ }
72+
5673/// Removes eight spaces of leading indentation from a multiline string.
5774///
5875/// Note that this is very sensitive to how the literals are styled. They should
Original file line number Diff line number Diff line change @@ -992,21 +992,25 @@ void main() {
992992 });
993993
994994 group ('6.8: Directives' , () {
995- // TODO(nweiz): assert that this produces a warning
996995 test ('[Example 6.13]' , () {
997- expectYamlLoads ('foo' , '''
996+ expectYamlLoadsWithWarning (
997+ 'foo' ,
998+ '''
998999 %FOO bar baz # Should be ignored
9991000 # with a warning.
1000- --- "foo"''' );
1001+ --- "foo"''' ,
1002+ 'unknown directive.' );
10011003 });
10021004
1003- // TODO(nweiz): assert that this produces a warning.
10041005 test ('[Example 6.14]' , () {
1005- expectYamlLoads ('foo' , '''
1006+ expectYamlLoadsWithWarning (
1007+ 'foo' ,
1008+ '''
10061009 %YAML 1.3 # Attempt parsing
10071010 # with a warning
10081011 ---
1009- "foo"''' );
1012+ "foo"''' ,
1013+ 'this parser only supports YAML 1.1 and 1.2.' );
10101014 });
10111015
10121016 test ('[Example 6.15]' , () {
You can’t perform that action at this time.
0 commit comments