root/as3/OverloadSupport/tests/org/libspark/utils/overload/OverloadSupportTest.as

リビジョン 134, 2.8 kB (コミッタ: yossy, コミット時期: 1 年 前)

Fixed package.

  • svn:keywords 属性の設定値: URL Author Date Rev Id
Line 
1 /*
2  * Copyright(c) 2006-2007 the Spark project.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific language
14  * governing permissions and limitations under the License.
15  */
16
17 package org.libspark.utils.overload
18 {
19     import org.libspark.as3unit.test;
20     import org.libspark.as3unit.assert.assertEquals;
21    
22     use namespace test;
23    
24     /**
25      * OverloadSupport のテストケースです
26      *
27      * @author yossy
28      */
29     public final class OverloadSupportTest
30     {
31         test function invoke():void
32         {
33             var hoge:Hoge = new Hoge();
34            
35             Static.log = '';
36            
37             hoge.func();
38             hoge.func('str');
39             hoge.func('str1', 'str2');
40             hoge.func(1024);
41             hoge.func('sss', 512);
42            
43             assertEquals('Default String(str) String(str1)String(str2) Int(1024) String(sss)Int(512) ', Static.log);
44         }
45     }
46 }
47
48 import org.libspark.utils.overload.OverloadSupport;
49 import org.libspark.utils.overload.overloadDefault;
50
51 namespace overloadString;
52 namespace overloadStringString;
53 namespace overloadInt;
54 namespace overloadStringInt;
55
56 use namespace overloadString;
57 use namespace overloadStringString;
58 use namespace overloadInt;
59 use namespace overloadStringInt;
60 use namespace overloadDefault;
61
62 class Static
63 {
64     public static var log:String = '';
65 }
66
67 class Hoge
68 {
69     OverloadSupport.register(overloadString, String);
70     OverloadSupport.register(overloadStringString, String, String);
71     OverloadSupport.register(overloadInt, int);
72     OverloadSupport.register(overloadStringInt, String, int);
73    
74     public function func(...args):void
75     {
76         OverloadSupport.invoke(this, 'func', args);
77     }
78    
79     overloadDefault function func():void
80     {
81         Static.log += 'Default ';
82     }
83    
84     overloadString function func(a:String):void
85     {
86         Static.log += 'String(' + a + ') ';
87     }
88    
89     overloadStringString function func(a:String, b:String):void
90     {
91         Static.log += 'String(' + a + ')String(' + b + ') ';
92     }
93    
94     overloadInt function func(a:int):void
95     {
96         Static.log += 'Int(' + a + ') ';
97     }
98    
99     overloadStringInt function func(a:String, b:int):void
100     {
101         Static.log += 'String(' + a + ')Int(' + b + ') ';
102     }
103 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。