tests: test_syntax now reports other errors before the pkgconfig error
[nit.git] / contrib / mnit_test / src / test_data_store.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Test for the shared_preferences module of App.nit framework
18 module test_data_store
19
20 import simple
21 import app::data_store
22
23 redef class App
24 redef fun on_create
25 do
26 super
27
28 # load colors from data store
29 var r = data_store["r"]
30 if r isa Float then
31 self.r = r
32 print "r {r}"
33 else assert r == null
34
35 var g = data_store["g"]
36 if g isa Float then
37 self.g = g
38 print "g {g}"
39 else assert g == null
40 end
41
42 redef fun input(ie)
43 do
44 if ie isa PointerEvent then
45 # save color for next execution
46 data_store["r"] = r
47 data_store["g"] = g
48 end
49
50 return super
51 end
52 end