diff options
Diffstat (limited to 'spec/inputs/test/yaml_string_spec.yue')
| -rw-r--r-- | spec/inputs/test/yaml_string_spec.yue | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/spec/inputs/test/yaml_string_spec.yue b/spec/inputs/test/yaml_string_spec.yue index 1296340..0a7d61b 100644 --- a/spec/inputs/test/yaml_string_spec.yue +++ b/spec/inputs/test/yaml_string_spec.yue | |||
| @@ -3,15 +3,15 @@ describe "yaml string", -> | |||
| 3 | s = | | 3 | s = | |
| 4 | hello | 4 | hello |
| 5 | world | 5 | world |
| 6 | assert.is_true s\match "hello" | 6 | assert.is_true s\match("hello")? |
| 7 | assert.is_true s\match "world" | 7 | assert.is_true s\match("world")? |
| 8 | 8 | ||
| 9 | it "should preserve indentation", -> | 9 | it "should preserve indentation", -> |
| 10 | s = | | 10 | s = | |
| 11 | key1: value1 | 11 | key1: value1 |
| 12 | key2: value2 | 12 | key2: value2 |
| 13 | assert.is_true s\match "key1" | 13 | assert.is_true s\match("key1")? |
| 14 | assert.is_true s\match "key2" | 14 | assert.is_true s\match("key2")? |
| 15 | 15 | ||
| 16 | it "should support interpolation", -> | 16 | it "should support interpolation", -> |
| 17 | name = "test" | 17 | name = "test" |
| @@ -25,13 +25,13 @@ describe "yaml string", -> | |||
| 25 | point: | 25 | point: |
| 26 | x: #{x} | 26 | x: #{x} |
| 27 | y: #{y} | 27 | y: #{y} |
| 28 | assert.is_true s\match "x: 10" | 28 | assert.is_true s\match("x: 10")? |
| 29 | assert.is_true s\match "y: 20" | 29 | assert.is_true s\match("y: 20")? |
| 30 | 30 | ||
| 31 | it "should work with expressions", -> | 31 | it "should work with expressions", -> |
| 32 | s = | | 32 | s = | |
| 33 | result: #{1 + 2} | 33 | result: #{1 + 2} |
| 34 | assert.is_true s\match "result: 3" | 34 | assert.is_true s\match("result: 3")? |
| 35 | 35 | ||
| 36 | it "should support multiline with variables", -> | 36 | it "should support multiline with variables", -> |
| 37 | config = | | 37 | config = | |
| @@ -39,15 +39,17 @@ describe "yaml string", -> | |||
| 39 | host: localhost | 39 | host: localhost |
| 40 | port: 5432 | 40 | port: 5432 |
| 41 | name: mydb | 41 | name: mydb |
| 42 | assert.is_true config\match "database:" | 42 | assert.is_true config\match("database:")? |
| 43 | assert.is_true config\match "host:" | 43 | assert.is_true config\match("host:")? |
| 44 | 44 | ||
| 45 | it "should escape special characters", -> | 45 | it "should escape special characters", -> |
| 46 | Hello = "Hello" | ||
| 46 | s = | | 47 | s = | |
| 47 | path: "C:\Program Files\App" | 48 | path: "C:\Program Files\App" |
| 48 | note: 'He said: "#{Hello}!"' | 49 | note: 'He said: "#{Hello}!"' |
| 49 | assert.is_true s\match "path:" | 50 | assert.same s, [[ |
| 50 | assert.is_true s\match "note:" | 51 | path: "C:\Program Files\App" |
| 52 | note: 'He said: "Hello!"']] | ||
| 51 | 53 | ||
| 52 | it "should work in function", -> | 54 | it "should work in function", -> |
| 53 | fn = -> | 55 | fn = -> |
| @@ -57,8 +59,7 @@ describe "yaml string", -> | |||
| 57 | return str | 59 | return str |
| 58 | 60 | ||
| 59 | result = fn! | 61 | result = fn! |
| 60 | assert.is_true result\match "foo:" | 62 | assert.same result, "foo:\n\tbar: baz" |
| 61 | assert.is_true result\match "bar:" | ||
| 62 | 63 | ||
| 63 | it "should strip common leading whitespace", -> | 64 | it "should strip common leading whitespace", -> |
| 64 | fn = -> | 65 | fn = -> |
| @@ -68,40 +69,39 @@ describe "yaml string", -> | |||
| 68 | s | 69 | s |
| 69 | 70 | ||
| 70 | result = fn! | 71 | result = fn! |
| 71 | assert.is_true result\match "nested:" | 72 | assert.same result, "nested: |
| 72 | assert.is_true result\match "item:" | 73 | item: value" |
| 73 | 74 | ||
| 74 | it "should support empty lines", -> | 75 | it "should support empty lines", -> |
| 75 | s = | | 76 | s = | |
| 76 | line1 | 77 | line1 |
| 77 | 78 | ||
| 78 | line3 | 79 | line3 |
| 79 | assert.is_true s\match "line1" | 80 | assert.same s, "line1\nline3" |
| 80 | assert.is_true s\match "line3" | ||
| 81 | 81 | ||
| 82 | it "should work with table access in interpolation", -> | 82 | it "should work with table access in interpolation", -> |
| 83 | t = {value: 100} | 83 | t = {value: 100} |
| 84 | s = | | 84 | s = | |
| 85 | value: #{t.value} | 85 | value: #{t.value} |
| 86 | assert.is_true s\match "value: 100" | 86 | assert.same s, "value: 100" |
| 87 | 87 | ||
| 88 | it "should support function calls in interpolation", -> | 88 | it "should support function calls in interpolation", -> |
| 89 | s = | | 89 | s = | |
| 90 | result: #{(-> 42)!} | 90 | result: #{(-> 42)!} |
| 91 | assert.is_true s\match "result: 42" | 91 | assert.same s, "result: 42" |
| 92 | 92 | ||
| 93 | it "should handle quotes correctly", -> | 93 | it "should handle quotes correctly", -> |
| 94 | s = | | 94 | s = | |
| 95 | "quoted" | 95 | "quoted" |
| 96 | 'single quoted' | 96 | 'single quoted' |
| 97 | assert.is_true s\match '"quoted"' | 97 | assert.is_true s\match('"quoted"')? |
| 98 | assert.is_true s\match "'single quoted'" | 98 | assert.is_true s\match("'single quoted'")? |
| 99 | 99 | ||
| 100 | it "should work with multiple interpolations", -> | 100 | it "should work with multiple interpolations", -> |
| 101 | a, b, c = 1, 2, 3 | 101 | a, b, c = 1, 2, 3 |
| 102 | s = | | 102 | s = | |
| 103 | values: #{a}, #{b}, #{c} | 103 | values: #{a}, #{b}, #{c} |
| 104 | assert.is_true s\match "values: 1, 2, 3" | 104 | assert.same s, "values: 1, 2, 3" |
| 105 | 105 | ||
| 106 | it "should preserve newlines", -> | 106 | it "should preserve newlines", -> |
| 107 | s = | | 107 | s = | |
