Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["tests._base.declare"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["tests._base.declare"] = true;
3
dojo.provide("tests._base.declare");
4
 
5
tests.register("tests._base.declare",
6
	[
7
		function smokeTest(t){
8
			dojo.declare("tests._base.declare.tmp");
9
			var tmp = new tests._base.declare.tmp();
10
			dojo.declare("testsFoo");
11
			var tmp = new testsFoo();
12
		},
13
		function smokeTest2(t){
14
			dojo.declare("tests._base.declare.foo", null, {
15
				foo: "thonk"
16
			});
17
			var tmp = new tests._base.declare.foo();
18
			t.is("thonk", tmp.foo);
19
 
20
			dojo.declare("testsFoo2", null, {
21
				foo: "thonk"
22
			});
23
			var tmp2 = new testsFoo2();
24
			t.is("thonk", tmp2.foo);
25
		},
26
		function smokeTestWithCtor(t){
27
			dojo.declare("tests._base.declare.fooBar", null, {
28
				constructor: function(){
29
					this.foo = "blah";
30
				},
31
				foo: "thonk"
32
			});
33
			var tmp = new tests._base.declare.fooBar();
34
			t.is("blah", tmp.foo);
35
		},
36
		function smokeTestCompactArgs(t){
37
			dojo.declare("tests._base.declare.fooBar2", null, {
38
				foo: "thonk"
39
			});
40
			var tmp = new tests._base.declare.fooBar2();
41
			t.is("thonk", tmp.foo);
42
		},
43
		function subclass(t){
44
			dojo.declare("tests._base.declare.tmp3", null, {
45
				foo: "thonk"
46
			});
47
			dojo.declare("tests._base.declare.tmp4", tests._base.declare.tmp3);
48
			var tmp = new tests._base.declare.tmp4();
49
			t.is("thonk", tmp.foo);
50
		},
51
		function subclassWithCtor(t){
52
			dojo.declare("tests._base.declare.tmp5", null, {
53
				constructor: function(){
54
					this.foo = "blah";
55
				},
56
				foo: "thonk"
57
			});
58
			dojo.declare("tests._base.declare.tmp6", tests._base.declare.tmp5);
59
			var tmp = new tests._base.declare.tmp6();
60
			t.is("blah", tmp.foo);
61
		},
62
		function mixinSubclass(t){
63
			dojo.declare("tests._base.declare.tmp7", null, {
64
				foo: "thonk"
65
			});
66
			dojo.declare("tests._base.declare.tmp8", null, {
67
				constructor: function(){
68
					this.foo = "blah";
69
				}
70
			});
71
			var tmp = new tests._base.declare.tmp8();
72
			t.is("blah", tmp.foo);
73
			dojo.declare("tests._base.declare.tmp9",
74
				[
75
					tests._base.declare.tmp7, // prototypal
76
					tests._base.declare.tmp8  // mixin
77
				]);
78
			var tmp2 = new tests._base.declare.tmp9();
79
			t.is("blah", tmp2.foo);
80
		},
81
		function superclassRef(t){
82
			dojo.declare("tests._base.declare.tmp10", null, {
83
				foo: "thonk"
84
			});
85
			dojo.declare("tests._base.declare.tmp11", tests._base.declare.tmp10, {
86
				constructor: function(){
87
					this.foo = "blah";
88
				}
89
			});
90
			var tmp = new tests._base.declare.tmp11();
91
			t.is("blah", tmp.foo);
92
			t.is("thonk", tests._base.declare.tmp11.superclass.foo);
93
		},
94
		function inheritedCall(t){
95
			var foo = "xyzzy";
96
			dojo.declare("tests._base.declare.tmp12", null, {
97
				foo: "thonk",
98
				bar: function(arg1, arg2){
99
					if(arg1){
100
						this.foo = arg1;
101
					}
102
					if(arg2){
103
						foo = arg2;
104
					}
105
				}
106
			});
107
			dojo.declare("tests._base.declare.tmp13", tests._base.declare.tmp12, {
108
				constructor: function(){
109
					this.foo = "blah";
110
				}
111
			});
112
			var tmp = new tests._base.declare.tmp13();
113
			t.is("blah", tmp.foo);
114
			t.is("xyzzy", foo);
115
			tmp.bar("zot");
116
			t.is("zot", tmp.foo);
117
			t.is("xyzzy", foo);
118
			tmp.bar("trousers", "squiggle");
119
			t.is("trousers", tmp.foo);
120
			t.is("squiggle", foo);
121
		},
122
		function inheritedExplicitCall(t){
123
			var foo = "xyzzy";
124
			dojo.declare("tests._base.declare.tmp14", null, {
125
				foo: "thonk",
126
				bar: function(arg1, arg2){
127
					if(arg1){
128
						this.foo = arg1;
129
					}
130
					if(arg2){
131
						foo = arg2;
132
					}
133
				}
134
			});
135
			dojo.declare("tests._base.declare.tmp15", tests._base.declare.tmp14, {
136
				constructor: function(){
137
					this.foo = "blah";
138
				},
139
				bar: function(arg1, arg2){
140
					this.inherited("bar", arguments, [arg2, arg1]);
141
				},
142
				baz: function(arg1, arg2){
143
					tests._base.declare.tmp15.superclass.bar.apply(this, arguments);
144
				}
145
			});
146
			var tmp = new tests._base.declare.tmp15();
147
			t.is("blah", tmp.foo);
148
			t.is("xyzzy", foo);
149
			tmp.baz("zot");
150
			t.is("zot", tmp.foo);
151
			t.is("xyzzy", foo);
152
			tmp.bar("trousers", "squiggle");
153
			t.is("squiggle", tmp.foo);
154
			t.is("trousers", foo);
155
		},
156
		function inheritedMixinCalls(t){
157
			dojo.declare("tests._base.declare.tmp16", null, {
158
				foo: "",
159
				bar: function(){
160
					this.foo += "tmp16";
161
				}
162
			});
163
			dojo.declare("tests._base.declare.mixin16", null, {
164
				bar: function(){
165
					this.inherited(arguments);
166
					this.foo += ".mixin16";
167
				}
168
			});
169
			dojo.declare("tests._base.declare.mixin17", tests._base.declare.mixin16, {
170
				bar: function(){
171
					this.inherited(arguments);
172
					this.foo += ".mixin17";
173
				}
174
			});
175
			dojo.declare("tests._base.declare.tmp17", [tests._base.declare.tmp16, tests._base.declare.mixin17], {
176
				bar: function(){
177
					this.inherited(arguments);
178
					this.foo += ".tmp17";
179
				}
180
			});
181
			var tmp = new tests._base.declare.tmp17();
182
			tmp.bar();
183
			t.is("tmp16.mixin16.mixin17.tmp17", tmp.foo);
184
		},
185
		function mixinPreamble(t){
186
			var passed = false;
187
			dojo.declare("tests._base.declare.tmp16");
188
			new tests._base.declare.tmp16({ preamble: function(){ passed = true; } });
189
			t.t(passed);
190
		}
191
		// FIXME: there are still some permutations to test like:
192
		//	- ctor arguments
193
		//	- multi-level inheritance + L/R conflict checks
194
	]
195
);
196
 
197
}