tests: Add test_astbuilder to the skip list of nitcg niti nitvm
[nit.git] / benchmarks / languages / benches / bench_typetest_depth.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
18 class TypeTestDepthGenerator
19 super Generator
20
21 redef fun initnit(res)
22 do
23 for c in classes do
24 res.add "new {c}[Root]"
25 end
26
27 end
28
29 redef fun testnit
30 do
31 return "a isa {classes[middle]}[Root]"
32 end
33
34 redef fun initjava(res, interfaces)
35 do
36
37 var tagc = ""
38 if interfaces then tagc = "X"
39 for c in classes do
40 res.add "new {tagc}{c}<Root>()"
41 end
42 end
43
44 redef fun testjava(interfaces)
45 do
46 return "a instanceof {classes[middle]}"
47 end
48
49 redef fun initcsharp(res, interfaces)
50 do
51 var tagc = ""
52 if interfaces then tagc = "X"
53 for c in classes do
54 res.add "new {tagc}{c}<Root>()"
55 end
56 end
57
58 redef fun testcsharp(interfaces)
59 do
60 return "a is {classes[middle]}<Root>"
61 end
62
63 redef fun initscala(res, interfaces)
64 do
65 var tagc = ""
66 if interfaces then tagc = "X"
67 for c in classes do
68 res.add "new {tagc}{c}[Root]()"
69 end
70 end
71
72 redef fun testscala(interfaces)
73 do
74 return "a.isInstanceOf[{classes[middle]}[Root]]"
75 end
76
77 redef fun initcpp(res)
78 do
79 for c in classes do
80 res.add "new {c}<Root>()"
81 end
82 end
83
84 redef fun testcpp
85 do
86 write "\t\t\t{classes[middle]}<Root> *to = dynamic_cast<{classes[middle]}<Root>*>(a);"
87 return "to != 0"
88 end
89
90 redef fun inite(res, se)
91 do
92 for c in classes do
93 res.add "create \{{c}[ROOT]\}"
94 end
95 end
96
97 redef fun teste(se)
98 do
99 write "\t\t\t\t\tto ?= a"
100 return "to /= Void"
101 end
102
103 redef fun locale(se)
104 do
105 write "\t\t\tto: detachable {classes[middle]}[ROOT]"
106 end
107
108 redef fun initpython(res)
109 do
110 for c in classes do
111 res.add "{c}()"
112 end
113 end
114 redef fun testpython
115 do
116 return "isinstance(a, {classes[middle]})"
117 end
118 end
119
120 var g = new TypeTestDepthGenerator
121 g.genall