gamnit: make `SpriteSet` public so clients can use its services
[nit.git] / benchmarks / languages / benches / bench_typetest_depth_not.nit
1 #!/usr/bin/env nit
2 # This file is part of NIT ( http://www.nitlanguage.org ).
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, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 import bench_base
17 import pipeline
18
19 class TypeTestDepthNotGenerator
20 super Generator
21
22 redef fun initnit(res)
23 do
24 res.add "new {classes.last}[Root]"
25 for c in classes.iterator.skip_tail(1) do
26 res.add "new {c}[Root]"
27 end
28 end
29
30 redef fun testnit
31 do
32 return "not a isa {classes.last}[Root]"
33 end
34
35 redef fun initjava(res, interfaces)
36 do
37
38 var tagc = ""
39 if interfaces then tagc = "X"
40 res.add "new {tagc}{classes.last}<Root>()"
41 for c in classes.iterator.skip_tail(1) do
42 res.add "new {tagc}{c}<Root>()"
43 end
44 end
45
46 redef fun testjava(interfaces)
47 do
48 return "!(a instanceof {classes.last})"
49 end
50
51 redef fun initcsharp(res, interfaces)
52 do
53 var tagc = ""
54 if interfaces then tagc = "X"
55 res.add "new {tagc}{classes.last}<Root>()"
56 for c in classes.iterator.skip_tail(1) do
57 res.add "new {tagc}{c}<Root>()"
58 end
59 end
60
61 redef fun testcsharp(interfaces)
62 do
63 return "!(a is {classes.last}<Root>)"
64 end
65
66 redef fun initscala(res, interfaces)
67 do
68 var tagc = ""
69 if interfaces then tagc = "X"
70 res.add "new {tagc}{classes.last}[Root]()"
71 for c in classes.iterator.skip_tail(1) do
72 res.add "new {tagc}{c}[Root]()"
73 end
74 end
75
76 redef fun testscala(interfaces)
77 do
78 return "!a.isInstanceOf[{classes.last}[Root]]"
79 end
80
81 redef fun initcpp(res)
82 do
83 res.add "new {classes.last}<Root>()"
84 for c in classes.iterator.skip_tail(1) do
85 res.add "new {c}<Root>()"
86 end
87 end
88
89 redef fun testcpp
90 do
91 write "\t\t\t{classes.last}<Root> *to = dynamic_cast<{classes.last}<Root>*>(a);"
92 return "to == 0"
93 end
94
95 redef fun inite(res, se)
96 do
97 res.add "create \{{classes.last}[ROOT]\}"
98 for c in classes.iterator.skip_tail(1) do
99 res.add "create \{{c}[ROOT]\}"
100 end
101 end
102
103 redef fun teste(se)
104 do
105 write "\t\t\t\t\tto ?= a"
106 return "to = Void"
107 end
108
109 redef fun locale(se)
110 do
111 write "\t\t\tto: detachable {classes.last}[ROOT]"
112 end
113
114 redef fun initpython(res)
115 do
116 res.add "{classes.last}()"
117 for c in classes.iterator.skip_tail(1) do
118 res.add "{c}()"
119 end
120 end
121 redef fun testpython
122 do
123 return "not isinstance(a, {classes.last})"
124 end
125 end
126
127 var g = new TypeTestDepthNotGenerator
128 g.genall