Skip to content

Commit 7bcec28

Browse files
Lord-McSweeneytorokati44
authored andcommitted
tests: Add test for confirming that target getter is called to determine whether to call clone
Test written by Adrian17
1 parent 39e6413 commit 7bcec28

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// compiled with mxmlc
2+
3+
import flash.events.Event;
4+
import flash.display.DisplayObject;
5+
6+
package {
7+
import flash.display.MovieClip;
8+
import flash.display.DisplayObject;
9+
import flash.events.Event;
10+
11+
public class Test extends MovieClip {
12+
public function Test(){
13+
var d = new MovieClip();
14+
trace("// testing trivial getter")
15+
var e1 = new E1("e1", d);
16+
d.dispatchEvent(e1);
17+
18+
trace("// testing 1-cycle-delayed getter")
19+
var e2 = new E2("e2", d);
20+
d.dispatchEvent(e2);
21+
}
22+
23+
}
24+
}
25+
26+
27+
class E1 extends Event {
28+
private var dobj: DisplayObject;
29+
public function E1(type, dobj){
30+
super(type, false, false);
31+
this.dobj = dobj;
32+
}
33+
override public function get target(): Object {
34+
trace("in get target()");
35+
return this.dobj;
36+
}
37+
override public function clone(): Event {
38+
trace("in clone()");
39+
return new E1(this.type, this.dobj);
40+
}
41+
}
42+
43+
class E2 extends Event {
44+
private var ready: Boolean;
45+
private var dobj: DisplayObject;
46+
public function E2(type, d){
47+
super(type, false, false);
48+
this.ready = false;
49+
this.dobj = dobj;
50+
}
51+
override public function get target(): Object {
52+
trace("in get target()");
53+
if (this.ready) {
54+
return this.dobj;
55+
}
56+
this.ready = true;
57+
return null;
58+
}
59+
override public function clone(): Event {
60+
trace("in clone()");
61+
return new E2(this.type, this.dobj);
62+
}
63+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// testing trivial getter
2+
in get target()
3+
in clone()
4+
// testing 1-cycle-delayed getter
5+
in get target()
959 Bytes
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# The test observes dispatcher accessing `.target` to check if event is being re-dispatched.
2+
num_frames = 1

0 commit comments

Comments
 (0)