Clone
Gustaf Neumann <neumann@wu-wien.ac.at>
committed
on 05 Jul 22
Added support for compiling with Tcl 9.0 (Many Thanks to Jan Nijtmans for first steps)
This version compiles cleanly at least with Tcl 8.6.*… Show more
Added support for compiling with Tcl 9.0 (Many Thanks to Jan Nijtmans for first steps)

This version compiles cleanly at least with Tcl 8.6.* and Tcl 9.0 (fossil trunk),

having -pedantic and -Wextra defined.

Show less

define-incrementals + 2 more
tests/double-alias.tcl (deleted)
1   package prefer latest
2   package require nx::test
3  
4  
5   nx::test case alias-redefine-method1 {
6       #
7       # redefine an object method by an alias pointing to an alias
8       #
9       proc ::foo args {;}
10      
11       nx::Object create o
12       ? {::o public object method BAR {} {;}} ::o::BAR
13       ? {::nsf::method::alias ::o bar ::foo} ::o::bar
14  
15       ? {info commands ::o::bar} ::o::bar              "::o::bar exists"
16       ? {info commands ::o::BAR} ::o::BAR              "a command ::o::BAR exists"
17       ? {::nsf::method::alias o BAR ::o::bar} ::o::BAR "redefine an object method with an alias (pointing to an alias) 87a2"
18   }
19  
20   nx::test case alias-redefine-method2 {
21       #
22       # redefine an object method by an alias pointing to an object method
23       #
24       proc ::foo args {;}
25      
26       nx::Object create o
27       ? {::o public object method BAR {} {;}} ::o::BAR
28       ? {::o public object method FOO {} {;}} ::o::FOO
29  
30       ? {info commands ::o::FOO} ::o::FOO              "a command ::o::FOO exists"
31       ? {info commands ::o::BAR} ::o::BAR              "a command ::o::BAR exists"
32       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "redefine an object method with an alias (pointing to a method) 87a2"
33   }
34  
35  
36   nx::test case alias-double-alias-proc {
37  
38       proc ::foo args {;}
39       nx::Object create o
40  
41       ? {info commands ::o::FOO} ""                    "a command ::o::FOO' does not exist"
42       ? {info commands ::o::BAR} ""                    "a command ::o::BAR does not exist"
43       ? {::nsf::method::alias o FOO ::foo}    ::o::FOO "define an object alias based on existing ::foo"
44       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "define an object alias based on alias based on existing ::o::FOO"
45   }
46  
47   nx::test case alias-double-alias-define {
48       #
49       # same as alias-double-reference-proc, but method instead of proc as target of o::FOO
50       #
51       proc ::foo args {;}
52  
53       nx::Object create o
54       ? {::nsf::method::alias ::o bar ::foo} ::o::bar
55  
56       ? {info commands ::o::bar} ::o::bar              "::o::bar exists"
57       ? {info commands ::o::FOO} ""                    "a command ::o::FOO' does not exists"
58       ? {info commands ::o::BAR} ""                    "a command ::o::BAR does not exist"
59       ? {::nsf::method::alias o FOO ::o::bar} ::o::FOO "define an object alias based on existing ::o::bar"
60       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "define an object alias based on alias based on existing (?) ::o::bar"
61   }
62  
63  
64   nx::test case alias-double-alias-redefine {
65       #
66       # same as alias-double-reference-define, but redefined instead of new definition
67       #
68       proc ::foo args {;}
69      
70       nx::Object create o
71       ? {::nsf::method::alias ::o FOO ::foo} ::o::FOO
72       ? {::nsf::method::alias ::o bar ::foo} ::o::bar
73  
74       ? {info commands ::o::bar} ::o::bar              "::o::bar exists"
75       ? {info commands ::o::FOO} ::o::FOO              "a command ::o::FOO' exists"
76       ? {info commands ::o::BAR} ""                    "a command ::o::BAR does not exist"
77       ? {::nsf::method::alias o FOO ::o::bar} ::o::FOO "redefine an object alias based on existing ::o::bar"
78       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "define an object alias based on alias based on existing ::o::FOO"
79   }
80  
81   nx::test case alias-double-alias-redefine0 {
82       #
83       # same as alias-double-reference-define, but redefined second cmd instead of new definition
84       #
85       proc ::foo args {;}
86      
87       nx::Object create o
88       ? {::o public object method BAR {} {;}} ::o::BAR
89       ? {::nsf::method::alias ::o bar ::foo} ::o::bar
90  
91       ? {info commands ::o::bar} ::o::bar              "::o::bar exists"
92       ? {info commands ::o::FOO} ""                    "a command ::o::FOO' does not exist"
93       ? {info commands ::o::BAR} ::o::BAR              "a command ::o::BAR exists"
94       ? {::nsf::method::alias o FOO ::foo} ::o::FOO    "define an object alias based on existing ::foo"
95       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "redefine an object alias based on alias based on existing ::o::FOO 87a2"
96   }
97  
98   nx::test case alias-double-alias-redefine1 {
99       #
100       # same as alias-double-reference-define, but redefined second cmd instead of new definition
101       #
102       proc ::foo args {;}
103      
104       nx::Object create o
105       ? {::o public object method BAR {} {;}} ::o::BAR
106       ? {::nsf::method::alias ::o bar ::foo} ::o::bar
107  
108       ? {info commands ::o::bar} ::o::bar              "::o::bar exists"
109       ? {info commands ::o::FOO} ""                    "a command ::o::FOO' does not exist"
110       ? {info commands ::o::BAR} ::o::BAR              "a command ::o::BAR exists"
111       ? {::nsf::method::alias o FOO ::o::bar} ::o::FOO "define an object alias based on existing ::o::bar"
112       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "redefine an object alias based on alias based on existing ::o::FOO 87a2"
113   }
114  
115   nx::test case alias-double-alias-redefine2 {
116       #
117       # same as alias-double-reference-define, but redefined twice instead of new definition
118       #
119       proc ::foo args {;}
120      
121       nx::Object create o
122       ? {::nsf::method::alias ::o FOO ::foo} ::o::FOO
123       ? {::o public object method BAR {} {;}} ::o::BAR
124       ? {::nsf::method::alias ::o bar ::foo} ::o::bar
125  
126       ? {info commands ::o::bar} ::o::bar              "::o::bar exists"
127       ? {info commands ::o::FOO} ::o::FOO              "a command ::o::FOO' exists"
128       ? {info commands ::o::BAR} ::o::BAR              "a command ::o::BAR exists"
129       ? {::nsf::method::alias o FOO ::o::bar} ::o::FOO "redefine an object alias based on existing ::o::bar"
130       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "redefine an object alias based on alias based on existing ::o::FOO 87a2"
131   }
132  
133  
134  
135   nx::test case alias-double-alias-object-method-redefine {
136  
137       proc ::foo args {;}
138      
139       nx::Object create o
140       ? {::nsf::method::alias ::o FOO ::foo} ::o::FOO
141       ? {::o public object method bar {} {;}} ::o::bar
142  
143       ? {info commands ::o::bar} ::o::bar              "handle ::o::bar exists"
144       ? {info commands ::o::FOO} ::o::FOO              "a command ::o::FOO' exists"
145       ? {info commands ::o::BAR} ""                    "a command ::o::BAR does not exist"
146       ? {::nsf::method::alias o FOO ::o::bar} ::o::FOO "redefine an object alias based on existing (?) ::o::bar"
147       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "define an object alias based on alias based on existing ::o::FOO"
148       ? {info exists ::nsf::alias(::o,FOO,1)} 1
149       ? {info exists ::nsf::alias(::o,BAR,1)} 1
150      
151       o public object method bar {} {}
152       ? {info exists ::nsf::alias(::o,FOO,1)} 1
153       ? {info exists ::nsf::alias(::o,BAR,1)} 1
154   }
155  
156  
157   nx::test case alias-double-alias-object-method-redefine2 {
158  
159       proc ::foo args {;}
160      
161       nx::Object create o
162       ? {::nsf::method::alias ::o FOO ::foo} ::o::FOO
163       ? {::o public object method BAR {} {;}} ::o::BAR
164       ? {::o public object method bar {} {;}} ::o::bar
165  
166       ? {info commands ::o::bar} ::o::bar              "handle ::o::bar exists"
167       ? {info commands ::o::FOO} ::o::FOO              "a command ::o::FOO' exists"
168       ? {info commands ::o::BAR} ::o::BAR              "a command ::o::BAR does not exist"
169       ? {::nsf::method::alias o FOO ::o::bar} ::o::FOO "redefine an object alias based on existing (?) ::o::bar"
170       ? {::nsf::method::alias o BAR ::o::FOO} ::o::BAR "redefine an object alias based on alias based on existing ::o::FOO 87a2"
171   }
172  
173