@@ -6,27 +6,27 @@ describe "Normalize: case" do
66 end
77
88 it " normalizes case with var in cond" do
9- assert_expand_second " x = 1; case x; when 1; 'b'; end" , " if 1 === x\n 'b'\n end"
9+ assert_expand " x = 1; case x; when 1; 'b'; end" , " if 1 === x\n 'b'\n end"
1010 end
1111
1212 it " normalizes case with Path to is_a?" do
13- assert_expand_second " x = 1; case x; when Foo; 'b'; end" , " if x.is_a?(Foo)\n 'b'\n end"
13+ assert_expand " x = 1; case x; when Foo; 'b'; end" , " if x.is_a?(Foo)\n 'b'\n end"
1414 end
1515
1616 it " normalizes case with generic to is_a?" do
17- assert_expand_second " x = 1; case x; when Foo(T); 'b'; end" , " if x.is_a?(Foo(T))\n 'b'\n end"
17+ assert_expand " x = 1; case x; when Foo(T); 'b'; end" , " if x.is_a?(Foo(T))\n 'b'\n end"
1818 end
1919
2020 it " normalizes case with Path.class to is_a?" do
21- assert_expand_second " x = 1; case x; when Foo.class; 'b'; end" , " if x.is_a?(Foo.class)\n 'b'\n end"
21+ assert_expand " x = 1; case x; when Foo.class; 'b'; end" , " if x.is_a?(Foo.class)\n 'b'\n end"
2222 end
2323
2424 it " normalizes case with Generic.class to is_a?" do
25- assert_expand_second " x = 1; case x; when Foo(T).class; 'b'; end" , " if x.is_a?(Foo(T).class)\n 'b'\n end"
25+ assert_expand " x = 1; case x; when Foo(T).class; 'b'; end" , " if x.is_a?(Foo(T).class)\n 'b'\n end"
2626 end
2727
2828 it " normalizes case with many expressions in when" do
29- assert_expand_second " x = 1; case x; when 1, 2; 'b'; end" , " if (1 === x) || (2 === x)\n 'b'\n end"
29+ assert_expand " x = 1; case x; when 1, 2; 'b'; end" , " if (1 === x) || (2 === x)\n 'b'\n end"
3030 end
3131
3232 it " normalizes case with implicit call" do
@@ -70,39 +70,39 @@ describe "Normalize: case" do
7070 end
7171
7272 it " normalizes case with nil to is_a?" do
73- assert_expand_second " x = 1; case x; when nil; 'b'; end" , " if x.is_a?(::Nil)\n 'b'\n end"
73+ assert_expand " x = 1; case x; when nil; 'b'; end" , " if x.is_a?(::Nil)\n 'b'\n end"
7474 end
7575
7676 it " normalizes case with multiple expressions" do
77- assert_expand_second " x, y = 1, 2; case {x, y}; when {2, 3}; 4; end" , " if (2 === x) && (3 === y)\n 4\n end"
77+ assert_expand " x, y = 1, 2; case {x, y}; when {2, 3}; 4; end" , " if (2 === x) && (3 === y)\n 4\n end"
7878 end
7979
8080 it " normalizes case with multiple expressions and types" do
81- assert_expand_second " x, y = 1, 2; case {x, y}; when {Int32, Float64}; 4; end" , " if x.is_a?(Int32) && y.is_a?(Float64)\n 4\n end"
81+ assert_expand " x, y = 1, 2; case {x, y}; when {Int32, Float64}; 4; end" , " if x.is_a?(Int32) && y.is_a?(Float64)\n 4\n end"
8282 end
8383
8484 it " normalizes case with multiple expressions and implicit obj" do
85- assert_expand_second " x, y = 1, 2; case {x, y}; when {.foo, .bar}; 4; end" , " if x.foo && y.bar\n 4\n end"
85+ assert_expand " x, y = 1, 2; case {x, y}; when {.foo, .bar}; 4; end" , " if x.foo && y.bar\n 4\n end"
8686 end
8787
8888 it " normalizes case with multiple expressions and comma" do
89- assert_expand_second " x, y = 1, 2; case {x, y}; when {2, 3}, {4, 5}; 6; end" , " if ((2 === x) && (3 === y)) || ((4 === x) && (5 === y))\n 6\n end"
89+ assert_expand " x, y = 1, 2; case {x, y}; when {2, 3}, {4, 5}; 6; end" , " if ((2 === x) && (3 === y)) || ((4 === x) && (5 === y))\n 6\n end"
9090 end
9191
9292 it " normalizes case with multiple expressions with underscore" do
93- assert_expand_second " x, y = 1, 2; case {x, y}; when {2, _}; 4; end" , " if 2 === x\n 4\n end"
93+ assert_expand " x, y = 1, 2; case {x, y}; when {2, _}; 4; end" , " if 2 === x\n 4\n end"
9494 end
9595
9696 it " normalizes case with multiple expressions with all underscores" do
97- assert_expand_second " x, y = 1, 2; case {x, y}; when {_, _}; 4; end" , " if true\n 4\n end"
97+ assert_expand " x, y = 1, 2; case {x, y}; when {_, _}; 4; end" , " if true\n 4\n end"
9898 end
9999
100100 it " normalizes case with multiple expressions with all underscores twice" do
101- assert_expand_second " x, y = 1, 2; case {x, y}; when {_, _}, {_, _}; 4; end" , " if true\n 4\n end"
101+ assert_expand " x, y = 1, 2; case {x, y}; when {_, _}, {_, _}; 4; end" , " if true\n 4\n end"
102102 end
103103
104104 it " normalizes case with multiple expressions and non-tuple" do
105- assert_expand_second " x, y = 1, 2; case {x, y}; when 1; 4; end" , " if 1 === {x, y}\n 4\n end"
105+ assert_expand " x, y = 1, 2; case {x, y}; when 1; 4; end" , " if 1 === {x, y}\n 4\n end"
106106 end
107107
108108 it " normalizes case without when and else" do
@@ -122,6 +122,6 @@ describe "Normalize: case" do
122122 end
123123
124124 it " normalizes case with Path.class to is_a? (in)" do
125- assert_expand_second " x = 1; case x; in Foo.class; 'b'; end" , " if x.is_a?(Foo.class)\n 'b'\n else\n raise \" unreachable\"\n end"
125+ assert_expand " x = 1; case x; in Foo.class; 'b'; end" , " if x.is_a?(Foo.class)\n 'b'\n else\n raise \" unreachable\"\n end"
126126 end
127127end
0 commit comments