1+ package ;
2+
3+ import checkstyle .checks .ListenerNameCheck ;
4+
5+ class ListenerNameCheckTest extends CheckTestCase {
6+
7+ public function testCorrectListenerName (){
8+ var msg = checkMessage (ListernerTests .TEST , new ListenerNameCheck ());
9+ assertEquals (msg , ' ' );
10+ }
11+
12+ public function testListenerName1 (){
13+ var msg = checkMessage (ListernerTests .TEST1 , new ListenerNameCheck ());
14+ assertEquals (msg , ' Wrong listener name, prefix with "on": _testUpdate' );
15+ }
16+
17+ public function testListenerName2 (){
18+ var msg = checkMessage (ListernerTests .TEST2 , new ListenerNameCheck ());
19+ assertEquals (msg , ' Wrong listener name, prefix with "on": _testUpdate' );
20+ }
21+
22+ public function testListenerName3 (){
23+ var msg = checkMessage (ListernerTests .TEST3 , new ListenerNameCheck ());
24+ assertEquals (msg , ' Wrong listener name, prefix with "on": _testUpdate' );
25+ }
26+
27+ public function testListenerName4 (){
28+ var msg = checkMessage (ListernerTests .TEST4 , new ListenerNameCheck ());
29+ assertEquals (msg , ' Wrong listener name, prefix with "on": _testUpdate' );
30+ }
31+
32+ public function testListenerName5 (){
33+ var msg = checkMessage (ListernerTests .TEST5 , new ListenerNameCheck ());
34+ assertEquals (msg , ' Wrong listener name, prefix with "on": _testUpdate' );
35+ }
36+ }
37+
38+ class ListernerTests {
39+ public static inline var TEST : String = "
40+ class Test {
41+ var a:Stage;
42+ public function new() {
43+ a.addOnce('update', _onUpdate);
44+ }
45+
46+ function _onUpdate() {}
47+ }" ;
48+
49+ public static inline var TEST1 : String = "
50+ class Test {
51+ var a:Stage;
52+ public function new() {
53+ a.addEventListener('update', _testUpdate);
54+ }
55+
56+ function _testUpdate() {}
57+ }" ;
58+
59+ public static inline var TEST2 : String = "
60+ class Test {
61+ var a:Stage;
62+ public function new() {
63+ a.on('update', _testUpdate);
64+ }
65+
66+ function _testUpdate() {}
67+ }" ;
68+
69+ public static inline var TEST3 : String = "
70+ class Test {
71+ var a:Stage;
72+ public function new() {
73+ a.once('update', _testUpdate);
74+ }
75+
76+ function _testUpdate() {}
77+ }" ;
78+
79+ public static inline var TEST4 : String = "
80+ class Test {
81+ var a:Stage;
82+ public function new() {
83+ a.add('update', _testUpdate);
84+ }
85+
86+ function _testUpdate() {}
87+ }" ;
88+
89+ public static inline var TEST5 : String = "
90+ class Test {
91+ var a:Stage;
92+ public function new() {
93+ a.addOnce('update', _testUpdate);
94+ }
95+
96+ function _testUpdate() {}
97+ }" ;
98+ }
0 commit comments