/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

  1. REBOL [
  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. change-dir %../
  9. ~~~start-file~~~ "return-err"
  10. --test-- "return as last statement in until block"
  11. --compile-this "until [return]"
  12. --assert-msg? "*** Compilation Error: return is not allowed outside of a function"
  13. --clean
  14. --compile-this "foo: func [][until [return]]"
  15. --assert-msg? "*** Compilation Error: RETURN keyword used without return: declaration in foo"
  16. --clean
  17. --compile-this "foo: func [return: [integer!]][until [return]]"
  18. --assert-msg? "*** Compilation Error: missing argument"
  19. --clean
  20. --compile-this "foo: func [return: [integer!]][until [return true]]"
  21. --assert-msg? "*** Compilation Error: wrong return type in function: foo"
  22. --clean
  23. --compile-this "foo: func [return: [integer!]][until [return 123]]"
  24. --assert-msg? "*** Compilation Error: UNTIL requires a conditional expression"
  25. --clean
  26. ~~~end-file~~~