/red-system/tests/source/compiler/return-test.r
http://github.com/dockimbel/Red · R · 36 lines · 26 code · 10 blank · 0 comment · 0 complexity · 71d470e2918fee9b95607a5ae2463a3a MD5 · raw file
- REBOL [
- Title: "Red/System RETURN keyword test script"
- Author: "Nenad Rakocevic"
- File: %return-test.reds
- Rights: "Copyright (C) 2011 Nenad Rakocevic. All rights reserved."
- License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
- ]
- change-dir %../
- ~~~start-file~~~ "return-err"
- --test-- "return as last statement in until block"
- --compile-this "until [return]"
- --assert-msg? "*** Compilation Error: return is not allowed outside of a function"
- --clean
-
- --compile-this "foo: func [][until [return]]"
- --assert-msg? "*** Compilation Error: RETURN keyword used without return: declaration in foo"
- --clean
-
- --compile-this "foo: func [return: [integer!]][until [return]]"
- --assert-msg? "*** Compilation Error: missing argument"
- --clean
-
- --compile-this "foo: func [return: [integer!]][until [return true]]"
- --assert-msg? "*** Compilation Error: wrong return type in function: foo"
- --clean
-
- --compile-this "foo: func [return: [integer!]][until [return 123]]"
- --assert-msg? "*** Compilation Error: UNTIL requires a conditional expression"
- --clean
-
- ~~~end-file~~~