-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5699 from dcjones/goto
Add labels and gotos. (Fixes #101)
- Loading branch information
Showing
6 changed files
with
217 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1357,4 +1357,6 @@ export | |
@deprecate, | ||
@boundscheck, | ||
@inbounds, | ||
@simd | ||
@simd, | ||
@label, | ||
@goto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
# Basic goto tests | ||
|
||
function goto_test1() | ||
@goto a | ||
return false | ||
@label a | ||
return true | ||
end | ||
@test goto_test1() | ||
|
||
|
||
@test_throws ErrorException eval( | ||
quote | ||
function goto_test2() | ||
@goto a | ||
@label a | ||
@label a | ||
return | ||
end | ||
end) | ||
|
||
|
||
@test_throws ErrorException eval( | ||
quote | ||
function goto_test3() | ||
@goto a | ||
return | ||
end | ||
end) | ||
|
||
|
||
@test_throws ErrorException eval( | ||
quote | ||
function goto_test4() | ||
@goto a | ||
try | ||
@label a | ||
catch | ||
end | ||
end | ||
end) | ||
|
||
|
||
# test that labels in macros are reassigned | ||
macro goto_test5_macro() | ||
@label a | ||
end | ||
|
||
@test_throws ErrorException eval( | ||
quote | ||
function goto_test5() | ||
@goto a | ||
@goto_test5_macro | ||
return | ||
end | ||
end) | ||
|
||
|
||
@test_throws ErrorException eval( | ||
quote | ||
function goto_test6() | ||
try | ||
@goto a | ||
finally | ||
end | ||
@label a | ||
return | ||
end | ||
end) | ||
|