/red-system/tests/source/compiler/alias-test.r

http://github.com/dockimbel/Red · R · 71 lines · 59 code · 12 blank · 0 comment · 2 complexity · e3a7bf65bf37f7ce7b64d0fc5c3f2eaa MD5 · raw file

  1. REBOL [
  2. Title: "Red/System alias test script"
  3. Author: "Nenad Rakocevic & Peter W A Wood"
  4. File: %alias-test.r
  5. Rights: "Copyright (C) 2011 Nenad Rakocevic & Peter W A Wood. All rights reserved."
  6. License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
  7. ]
  8. change-dir %../
  9. compiled?: func [
  10. source [string!]
  11. ][
  12. write %runnable/alias.reds source
  13. exe: --compile src: %runnable/alias.reds
  14. if exists? %runnable/alias.reds [delete %runnable/alias.reds]
  15. if all [
  16. exe
  17. exists? exe
  18. ][
  19. delete exe
  20. ]
  21. qt/compile-ok?
  22. ]
  23. ~~~start-file~~~ "alias-compile"
  24. ===start-group=== "compiler checks"
  25. --test-- "alias-1"
  26. --assert compiled? {
  27. Red/System []
  28. a3-alias!: alias struct! [a [integer!] b [integer!]]
  29. a3-struct: declare a3-alias!
  30. a3-struct/a: 1
  31. a3-struct/b: 2
  32. a3-struct-1: declare a3-alias!
  33. a3-struct-1/a: 3
  34. a3-struct-1/b: 4
  35. }
  36. --test-- "alias-2"
  37. --assert compiled? {
  38. Red/System []
  39. a5-alias!: alias struct! [a [integer!] b [integer!]]
  40. a5-struct: declare a5-alias!
  41. a5-pointer: declare pointer! [integer!]
  42. a5-struct/a: 1
  43. a5-struct/b: 2
  44. a5-pointer: as [pointer! [integer!]] a5-struct
  45. a5-struct: as a5-alias! a5-pointer
  46. }
  47. --test-- "alias-3"
  48. --assert compiled? {
  49. Red/System []
  50. a5-alias!: alias struct! [a [byte!] b [byte!]]
  51. a6-alias!: alias struct! [a [byte!] b [byte!]]
  52. a6-struct: declare struct! [
  53. s1 [a5-alias!]
  54. s2 [a5-alias!]
  55. ]
  56. a6-struct/s1: declare a6-alias!
  57. }
  58. ===end-group===
  59. ~~~end-file~~~