Merge: Bench scripts
[nit.git] / tests / test_new_native.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 redef class NativeArray[E]
16 new(length: Int) is intern
17 end
18
19 redef class NativeString
20 new(length: Int) is intern
21 end
22
23 var s = new NativeString(4)
24 s[0] = 'N'
25 s[2] = 't'
26 s[1] = 'i'
27 s[3] = '\0'
28 print s.class_name
29 print s[0]
30 print s.to_s
31
32 var a: NativeArray[Object] = new NativeArray[Int](3)
33 a[0] = 1
34 a[1] = 10
35 a[2] = 100
36 #alt1#a[1] = true
37 print a.class_name
38 print a.length
39 print a[0]
40 print a.to_a.join(",")
41