Skip to content

Literal and folded strings cannot handle "\n \n" at the end of a string #1944

@jonasfj

Description

@jonasfj

Adding the test case 'whitespace between line breaks at the end\n \n' to test/string_test.dart causes tests to fail.

diff --git a/test/string_test.dart b/test/string_test.dart
index b92c20a..a18f57a 100644
--- a/test/string_test.dart
+++ b/test/string_test.dart
@@ -10,6 +10,7 @@ final _testStrings = [
   "this is a fairly' long string with\nline breaks",
   'whitespace\n after line breaks',
   'whitespace\n \nbetween line breaks',
+  'whitespace between line breaks at the end\n \n',
   '\n line break at the start',
   'word',
   'foo bar',

Tests failures:

$ dart test
00:01 +400 -1: loading test/golden_test.dart                                                                                                                                                                                           
Successfully tested 20 inputs against golden files, created 0 golden files
00:01 +400 -1: test/string_test.dart: Root FOLDED string (4) [E]                                                                                                                                                                       
  Assertion failed: (package:yaml_edit) Modification did not result in expected result.
  
  # YAML before edit:
  > 
  
  # YAML after edit:
  > >-
  >   whitespace between line breaks at the end
  >    
  >   
  
  Please file an issue at:
  https://github.com/dart-lang/yaml_edit/issues/new?labels=bug
  
  package:yaml_edit/src/editor.dart 579:7   YamlEditor._performEdit
  package:yaml_edit/src/editor.dart 249:14  YamlEditor.update
  test/string_test.dart 39:20               main.<fn>
  

To run this test again: dart test test/string_test.dart -p vm --plain-name 'Root FOLDED string (4)'
00:01 +415 -2: test/string_test.dart: Root LITERAL string (4) [E]                                                                                                                                                                      
  Assertion failed: (package:yaml_edit) Modification did not result in expected result.
  
  # YAML before edit:
  > 
  
  # YAML after edit:
  > |-
  >   whitespace between line breaks at the end
  >    
  >   
  
  Please file an issue at:
  https://github.com/dart-lang/yaml_edit/issues/new?labels=bug
  
  package:yaml_edit/src/editor.dart 579:7   YamlEditor._performEdit
  package:yaml_edit/src/editor.dart 249:14  YamlEditor.update
  test/string_test.dart 39:20               main.<fn>
  

To run this test again: dart test test/string_test.dart -p vm --plain-name 'Root LITERAL string (4)'
00:10 +624 -2: Some tests failed.                                                                                                                                                                                                      

Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'dart test --chain-stack-traces'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    package:yaml_edittype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions