Skip to content

Commit

Permalink
add destructuring assignment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haileys committed Oct 31, 2013
1 parent 9a90dfc commit 9149400
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/slash/destructuring_assignment.sl
@@ -0,0 +1,38 @@
<%
class DestructuringAssignmentTest extends Test {
def test_array_assignment {
[a, b, c] = [1, 2, 3];
assert_equal(1, a);
assert_equal(2, b);
assert_equal(3, c);
}
def test_array_assignment_2 {
[a, b, c] = [1, 2];
assert_equal(1, a);
assert_equal(2, b);
assert_equal(nil, c);
}
def test_array_assignment_2 {
[a, b, c] = 1;
assert_equal(1, a);
assert_equal(nil, b);
assert_equal(nil, c);
}
def test_nested_array_assignment {
[[a, b]] = [[1, 2], [3, 4]];
assert_equal(1, a);
assert_equal(2, b);
}
def test_nested_array_assignment_2 {
[[a, b]] = [1, [2, 3]];
assert_equal(1, a);
assert_equal(nil, b);
}
}

0 comments on commit 9149400

Please sign in to comment.