PageRenderTime 30ms CodeModel.GetById 15ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1REBOL [
 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
 9change-dir %../
10
11compiled?: func [
12  source [string!]
13][
14  write %runnable/alias.reds source 
15  exe: --compile src: %runnable/alias.reds
16  if exists? %runnable/alias.reds [delete %runnable/alias.reds]
17  if all [
18    exe
19    exists? exe
20  ][
21    delete exe
22  ]
23  qt/compile-ok?
24]
25  
26
27~~~start-file~~~ "alias-compile"
28
29===start-group=== "compiler checks"
30
31	--test-- "alias-1"
32	--assert compiled? {
33	  Red/System []
34	  a3-alias!: alias struct! [a [integer!] b [integer!]]
35	  a3-struct: declare a3-alias!
36	  a3-struct/a: 1
37	  a3-struct/b: 2
38	  a3-struct-1: declare a3-alias!
39	  a3-struct-1/a: 3
40	  a3-struct-1/b: 4
41  }
42  
43  --test-- "alias-2"
44  --assert compiled? {
45      Red/System []
46      a5-alias!: alias struct! [a [integer!] b [integer!]]
47      a5-struct: declare a5-alias!
48      a5-pointer: declare pointer! [integer!]
49      a5-struct/a: 1
50      a5-struct/b: 2
51      a5-pointer: as [pointer! [integer!]] a5-struct
52      a5-struct: as a5-alias! a5-pointer
53    }
54    
55  --test-- "alias-3"
56  --assert compiled? {
57    Red/System []  
58    a5-alias!: alias struct! [a [byte!] b [byte!]]
59    a6-alias!: alias struct! [a [byte!] b [byte!]]
60    a6-struct: declare struct! [
61      s1 [a5-alias!]
62      s2 [a5-alias!]
63    ]
64    a6-struct/s1: declare a6-alias!
65  }
66  
67===end-group=== 
68       
69~~~end-file~~~
70
71