PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 1REBOL [
 2	Title:   "Red/System RETURN keyword test script"
 3	Author:  "Nenad Rakocevic"
 4	File: 	 %return-test.reds
 5	Rights:  "Copyright (C) 2011 Nenad Rakocevic. All rights reserved."
 6	License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
 7]
 8
 9change-dir %../
10
11~~~start-file~~~ "return-err"
12
13  --test-- "return as last statement in until block"
14	--compile-this "until [return]"
15	--assert-msg? "*** Compilation Error: return is not allowed outside of a function"
16	--clean
17	
18	--compile-this "foo: func [][until [return]]"
19	--assert-msg? "*** Compilation Error: RETURN keyword used without return: declaration in foo"
20	--clean
21	
22	--compile-this "foo: func [return: [integer!]][until [return]]"
23	--assert-msg? "*** Compilation Error: missing argument"
24	--clean
25	
26	--compile-this "foo: func [return: [integer!]][until [return true]]"
27	--assert-msg? "*** Compilation Error: wrong return type in function: foo"
28	--clean
29	
30	--compile-this "foo: func [return: [integer!]][until [return 123]]"
31	--assert-msg? "*** Compilation Error: UNTIL requires a conditional expression"
32	--clean
33	
34~~~end-file~~~
35
36