From d6f0b49f6750f73e0dba1525c814557502304afb Mon Sep 17 00:00:00 2001 From: pwbh Date: Sun, 6 Oct 2024 21:37:14 +0300 Subject: [PATCH 1/3] Test case for J5UC --- resources/yaml-test-suite/J5UC.yml | 27 +++++++++++++++++++++++++ src/tests.zig | 32 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 resources/yaml-test-suite/J5UC.yml diff --git a/resources/yaml-test-suite/J5UC.yml b/resources/yaml-test-suite/J5UC.yml new file mode 100644 index 0000000..855a060 --- /dev/null +++ b/resources/yaml-test-suite/J5UC.yml @@ -0,0 +1,27 @@ +elements: + - name: Multiple Pair Block Mapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: mapping + yaml: | + foo: blue + bar: arrr + baz: jazz + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :blue + =VAL :bar + =VAL :arrr + =VAL :baz + =VAL :jazz + -MAP + -DOC + -STR + json: | + { + "foo": "blue", + "bar": "arrr", + "baz": "jazz" + } diff --git a/src/tests.zig b/src/tests.zig index a62ecce..6eb9029 100644 --- a/src/tests.zig +++ b/src/tests.zig @@ -211,3 +211,35 @@ test "QT73" { try expect(std.mem.eql(u8, element.name, "Comment and document-end marker")); try expect(std.mem.eql(u8, element.from, "@perlpunk")); } + +test "J5UC" { + const Element = struct { + name: []const u8, + from: []const u8, + tags: []const u8, + yaml: []const u8, + tree: []const u8, + json: []const u8, + }; + + const Experiment = struct { + elements: []Element, + }; + + const yml_file_location = try std.fs.cwd().realpathAlloc( + std.testing.allocator, + "./resources/yaml-test-suite/J5UC.yml", + ); + defer std.testing.allocator.free(yml_file_location); + + var ymlz = try Ymlz(Experiment).init(std.testing.allocator); + const result = try ymlz.loadFile(yml_file_location); + defer ymlz.deinit(result); + + std.debug.print("elements: {}\n", .{result.elements.len}); + + const element = result.elements[0]; + + try expect(std.mem.eql(u8, element.name, "Multiple Pair Block Mapping")); + try expect(std.mem.eql(u8, element.from, "https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml")); +} From d6a1f7826b42ddfe91fee001f8722cc5d95bb14f Mon Sep 17 00:00:00 2001 From: pwbh Date: Sun, 6 Oct 2024 21:37:51 +0300 Subject: [PATCH 2/3] new file indicator is not failing tests --- resources/yaml-test-suite/CC74.yml | 1 + resources/yaml-test-suite/J5UC.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/resources/yaml-test-suite/CC74.yml b/resources/yaml-test-suite/CC74.yml index 1211cb7..2411397 100644 --- a/resources/yaml-test-suite/CC74.yml +++ b/resources/yaml-test-suite/CC74.yml @@ -1,3 +1,4 @@ +--- elements: - name: Spec Example 6.20. Tag Handles from: http://www.yaml.org/spec/1.2/spec.html#id2783195 diff --git a/resources/yaml-test-suite/J5UC.yml b/resources/yaml-test-suite/J5UC.yml index 855a060..8f9fb97 100644 --- a/resources/yaml-test-suite/J5UC.yml +++ b/resources/yaml-test-suite/J5UC.yml @@ -1,3 +1,4 @@ +--- elements: - name: Multiple Pair Block Mapping from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml From 2fe6ef9693615ed470ee590b9639a3f99af7a2d4 Mon Sep 17 00:00:00 2001 From: pwbh Date: Sun, 6 Oct 2024 21:38:35 +0300 Subject: [PATCH 3/3] Add new line start --- resources/yaml-test-suite/98YD-mixed.yml | 3 ++- resources/yaml-test-suite/98YD.yml | 5 +++-- resources/yaml-test-suite/F6MC.yml | 1 + resources/yaml-test-suite/QT73.yml | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/yaml-test-suite/98YD-mixed.yml b/resources/yaml-test-suite/98YD-mixed.yml index 7986aa0..73cb287 100644 --- a/resources/yaml-test-suite/98YD-mixed.yml +++ b/resources/yaml-test-suite/98YD-mixed.yml @@ -1,3 +1,4 @@ +--- elemennts: - name: Spec Example 5.5. Comment Indicator from: http://www.yaml.org/spec/1.2/spec.html#id2773032 @@ -11,4 +12,4 @@ elemennts: dump: "" bool_val: true bool_val_b2: false - bool_val_with_spaces: true \ No newline at end of file + bool_val_with_spaces: true diff --git a/resources/yaml-test-suite/98YD.yml b/resources/yaml-test-suite/98YD.yml index 9d5fed6..92f7299 100644 --- a/resources/yaml-test-suite/98YD.yml +++ b/resources/yaml-test-suite/98YD.yml @@ -1,4 +1,5 @@ -elemennts: +--- +elements: - name: Spec Example 5.5. Comment Indicator from: http://www.yaml.org/spec/1.2/spec.html#id2773032 tags: spec comment empty @@ -8,4 +9,4 @@ elemennts: +STR -STR json: "" - dump: "" \ No newline at end of file + dump: "" diff --git a/resources/yaml-test-suite/F6MC.yml b/resources/yaml-test-suite/F6MC.yml index 7cad2f3..a491953 100644 --- a/resources/yaml-test-suite/F6MC.yml +++ b/resources/yaml-test-suite/F6MC.yml @@ -1,3 +1,4 @@ +--- elements: - name: More indented lines at the beginning of folded block scalars from: "@perlpunk" diff --git a/resources/yaml-test-suite/QT73.yml b/resources/yaml-test-suite/QT73.yml index 4c1a254..a9fff9e 100644 --- a/resources/yaml-test-suite/QT73.yml +++ b/resources/yaml-test-suite/QT73.yml @@ -1,3 +1,4 @@ +--- elements: - name: Comment and document-end marker from: "@perlpunk"