Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve YAML spec conformance by three tests #400

Merged
merged 1 commit into from May 9, 2019

Conversation

am11
Copy link
Contributor

@am11 am11 commented May 9, 2019

  • Relax the verison checks to support 1.1 to 1.3 range.
    • Fix up emitter to use version from DocumentStart object instead
      of constant.
  • Add YAML 1.2 escape character '/'
  • Improve grammar in SyntaxErrorException: find -> found to match
    with the counter part did not find (used in other cases).
  • Improve formatting of failing test error message in SpecTests.
    • Sample failure:
      Test Name:	YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec(name: "4ABK", description: "Spec Example 7.17. Flow Mapping Separate Values", inputFile: "C:\\Users\\adeel\\Source\\Repos\\yamldotnet\\YamlD"..., expectedEventFile: "C:\\Users\\adeel\\Source\\Repos\\yamldotnet\\YamlD"..., error: False)
      Test FullName:	YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec (04719e7467f756f24522681db96dacf88dbb3cd7)
      Test Source:	C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs : line 51
      Test Outcome:	Failed
      Test Duration:	0:00:00.332
      
      Result StackTrace:	at YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec(String name, String description, String inputFile, String expectedEventFile, Boolean error) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs:line 65
      Result Message:
      Unexpected spec failure.
      Expected:
      +STR
      +DOC
      +MAP
      =VAL :unquoted
      =VAL "separate
      =VAL :http://foo.com
      =VAL :
      =VAL :omitted value
      =VAL :
      =VAL :
      =VAL :omitted key
      -MAP
      -DOC
      -STR
      
      Actual:
      [Writer Output]
      +STR
      +DOC
      +MAP
      =VAL :unquoted
      =VAL "separate
      
      [Exception]
      YamlDotNet.Core.SyntaxErrorException: (Line: 3, Col: 1, Idx: 27) - (Line: 3, Col: 5, Idx: 31): While scanning a plain scalar, found unexpected ':'.
      at YamlDotNet.Core.Scanner.ScanPlainScalar() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 1867
      at YamlDotNet.Core.Scanner.FetchPlainScalar() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 1817
      at YamlDotNet.Core.Scanner.FetchNextToken() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 480
      at YamlDotNet.Core.Scanner.FetchMoreTokens() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 213
      at YamlDotNet.Core.Scanner.MoveNextWithoutConsuming() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 127
      at YamlDotNet.Core.Parser.GetCurrentToken() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 51
      at YamlDotNet.Core.Parser.ParseFlowMappingKey(Boolean isFirst) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 896
      at YamlDotNet.Core.Parser.StateMachine() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 187
      at YamlDotNet.Core.Parser.MoveNext() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 115
      at YamlDotNet.Test.Spec.SpecTests.ConvertToLibYamlStyleAnnotatedEventStream(TextReader textReader, TextWriter textWriter) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs:line 96
      at YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec(String name, String description, String inputFile, String expectedEventFile, Boolean error) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs:line 60
      Expected: True
      Actual:   False
      

Fixes specs:

  • UDM2 (Plain URL in flow mapping)
  • 3UYS (Escaped slash in double quotes)
  • 5MUD (Colon and adjacent value on next line)

Contributes to: #398

* Relax the verison checks to support 1.1 to 1.3 range.
  * Fix up emitter to use version from `DocumentStart` object instead
    of constant.
* Add YAML 1.2 escape character '/'
  * This was the only difference in escaped sequence between 1.1 and
    1.2: https://yaml.org/spec/1.1/#id872840 and
    https://yaml.org/spec/1.2/spec.html#id2776092
* Improve grammar in SyntaxErrorException: `find` -> `found` to match
  with the counter part `did not find` (used in other cases).
* Improve formatting of failing test error message in SpecTests.
  * <details>
    <summary>Sample failure:</summary>

    ```
    Test Name:	YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec(name: "4ABK", description: "Spec Example 7.17. Flow Mapping Separate Values", inputFile: "C:\\Users\\adeel\\Source\\Repos\\yamldotnet\\YamlD"..., expectedEventFile: "C:\\Users\\adeel\\Source\\Repos\\yamldotnet\\YamlD"..., error: False)
    Test FullName:	YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec (04719e7467f756f24522681db96dacf88dbb3cd7)
    Test Source:	C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs : line 51
    Test Outcome:	Failed
    Test Duration:	0:00:00.332

    Result StackTrace:	at YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec(String name, String description, String inputFile, String expectedEventFile, Boolean error) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs:line 65
    Result Message:
    Unexpected spec failure.
    Expected:
    +STR
    +DOC
    +MAP
    =VAL :unquoted
    =VAL "separate
    =VAL :http://foo.com
    =VAL :
    =VAL :omitted value
    =VAL :
    =VAL :
    =VAL :omitted key
    -MAP
    -DOC
    -STR

    Actual:
    [Writer Output]
    +STR
    +DOC
    +MAP
    =VAL :unquoted
    =VAL "separate

    [Exception]
    YamlDotNet.Core.SyntaxErrorException: (Line: 3, Col: 1, Idx: 27) - (Line: 3, Col: 5, Idx: 31): While scanning a plain scalar, found unexpected ':'.
    at YamlDotNet.Core.Scanner.ScanPlainScalar() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 1867
    at YamlDotNet.Core.Scanner.FetchPlainScalar() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 1817
    at YamlDotNet.Core.Scanner.FetchNextToken() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 480
    at YamlDotNet.Core.Scanner.FetchMoreTokens() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 213
    at YamlDotNet.Core.Scanner.MoveNextWithoutConsuming() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Scanner.cs:line 127
    at YamlDotNet.Core.Parser.GetCurrentToken() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 51
    at YamlDotNet.Core.Parser.ParseFlowMappingKey(Boolean isFirst) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 896
    at YamlDotNet.Core.Parser.StateMachine() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 187
    at YamlDotNet.Core.Parser.MoveNext() in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet\Core\Parser.cs:line 115
    at YamlDotNet.Test.Spec.SpecTests.ConvertToLibYamlStyleAnnotatedEventStream(TextReader textReader, TextWriter textWriter) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs:line 96
    at YamlDotNet.Test.Spec.SpecTests.ConformsWithYamlSpec(String name, String description, String inputFile, String expectedEventFile, Boolean error) in C:\Users\adeel\Source\Repos\yamldotnet\YamlDotNet.Test\Spec\SpecTests.cs:line 60
    Expected: True
    Actual:   False
    ```
    </details>

Fixes specs:

* [UDM2](https://github.com/yaml/yaml-test-suite/tree/data/UDM2) (Plain URL in flow mapping)
* [3UYS](https://github.com/yaml/yaml-test-suite/tree/data/3UYS) (Escaped slash in double quotes)
* [5MUD](https://github.com/yaml/yaml-test-suite/tree/data/5MUD) (Colon and adjacent value on next line)

Contributes to: aaubry#398
@aaubry aaubry merged commit cc70e04 into aaubry:master May 9, 2019
@aaubry
Copy link
Owner

aaubry commented May 9, 2019

Thanks!

@am11 am11 deleted the conformance branch May 9, 2019 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants