|
5 | 5 |
|
6 | 6 | module SyntaxTree
|
7 | 7 | class Formatter
|
8 |
| - class TestFormatter < Formatter |
9 |
| - prepend Formatter::SingleQuotes |
10 |
| - end |
11 |
| - |
12 |
| - def test_empty_string_literal |
13 |
| - assert_format("''\n", "\"\"") |
14 |
| - end |
15 |
| - |
16 |
| - def test_string_literal |
17 |
| - assert_format("'string'\n", "\"string\"") |
18 |
| - end |
19 |
| - |
20 |
| - def test_string_literal_with_interpolation |
21 |
| - assert_format("\"\#{foo}\"\n") |
22 |
| - end |
23 |
| - |
24 |
| - def test_dyna_symbol |
25 |
| - assert_format(":'symbol'\n", ":\"symbol\"") |
26 |
| - end |
27 |
| - |
28 |
| - def test_label |
29 |
| - assert_format( |
30 |
| - "{ foo => foo, :'bar' => bar }\n", |
31 |
| - "{ foo => foo, \"bar\": bar }" |
32 |
| - ) |
33 |
| - end |
34 |
| - |
35 |
| - private |
36 |
| - |
37 |
| - def assert_format(expected, source = expected) |
38 |
| - formatter = TestFormatter.new(source, []) |
39 |
| - SyntaxTree.parse(source).format(formatter) |
40 |
| - |
41 |
| - formatter.flush |
42 |
| - assert_equal(expected, formatter.output.join) |
| 8 | + class SingleQuotesTest < Minitest::Test |
| 9 | + class TestFormatter < Formatter |
| 10 | + prepend Formatter::SingleQuotes |
| 11 | + end |
| 12 | + |
| 13 | + def test_empty_string_literal |
| 14 | + assert_format("''\n", "\"\"") |
| 15 | + end |
| 16 | + |
| 17 | + def test_string_literal |
| 18 | + assert_format("'string'\n", "\"string\"") |
| 19 | + end |
| 20 | + |
| 21 | + def test_string_literal_with_interpolation |
| 22 | + assert_format("\"\#{foo}\"\n") |
| 23 | + end |
| 24 | + |
| 25 | + def test_dyna_symbol |
| 26 | + assert_format(":'symbol'\n", ":\"symbol\"") |
| 27 | + end |
| 28 | + |
| 29 | + def test_label |
| 30 | + assert_format( |
| 31 | + "{ foo => foo, :'bar' => bar }\n", |
| 32 | + "{ foo => foo, \"bar\": bar }" |
| 33 | + ) |
| 34 | + end |
| 35 | + |
| 36 | + private |
| 37 | + |
| 38 | + def assert_format(expected, source = expected) |
| 39 | + formatter = TestFormatter.new(source, []) |
| 40 | + SyntaxTree.parse(source).format(formatter) |
| 41 | + |
| 42 | + formatter.flush |
| 43 | + assert_equal(expected, formatter.output.join) |
| 44 | + end |
43 | 45 | end
|
44 | 46 | end
|
45 | 47 | end
|
0 commit comments