Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick committed May 19, 2021
1 parent 4c875c0 commit 4d7f3a7
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2699,20 +2699,22 @@ end
@test Meta.isexpr(Meta.@lower(f((; a, b::Int)) = a + b), :error)
end

# #33697 n-dimensional concatenation and vectors
@test :([1 2 5; 3 4 6;;; 0 9 3; 4 5 4]) ==
Expr(:ncat, 3, Expr(:nrow, 1, Expr(:row, 1, 2, 5), Expr(:row, 3, 4, 6)),
Expr(:nrow, 1, Expr(:row, 0, 9, 3), Expr(:row, 4, 5, 4)))
@test :([1 ; 2 ;; 3 ; 4]) == Expr(:ncat, 2, Expr(:nrow, 1, 1, 2), Expr(:nrow, 1, 3, 4))

@test_throws ParseError Meta.parse("[1 2 ;; 3 4]") # cannot mix spaces and ;; except as line break
@test :([1 2 ;;
3 4]) == :([1 2 3 4])
@test :([1 2 ;;
3 4 ; 2 3 4 5]) == :([1 2 3 4 ; 2 3 4 5])

Meta.parse("[1;\n]") == Expr(:vect, 1) # ensure line breaks following semicolons are treated correctly
Meta.parse("[1;\n\n]") == Expr(:vect, 1) # ensure line breaks following semicolons are treated correctly
# #33697
@testset "N-dimensional concatenation" begin
@test :([1 2 5; 3 4 6;;; 0 9 3; 4 5 4]) ==
Expr(:ncat, 3, Expr(:nrow, 1, Expr(:row, 1, 2, 5), Expr(:row, 3, 4, 6)),
Expr(:nrow, 1, Expr(:row, 0, 9, 3), Expr(:row, 4, 5, 4)))
@test :([1 ; 2 ;; 3 ; 4]) == Expr(:ncat, 2, Expr(:nrow, 1, 1, 2), Expr(:nrow, 1, 3, 4))

@test_throws ParseError Meta.parse("[1 2 ;; 3 4]") # cannot mix spaces and ;; except as line break
@test :([1 2 ;;
3 4]) == :([1 2 3 4])
@test :([1 2 ;;
3 4 ; 2 3 4 5]) == :([1 2 3 4 ; 2 3 4 5])

@test Meta.parse("[1;\n]") == :([1;]) # ensure line breaks following semicolons are treated correctly
@test Meta.parse("[1;\n\n]") == :([1;])
end

# issue #25652
x25652 = 1
Expand Down

0 comments on commit 4d7f3a7

Please sign in to comment.