mirah 0.0.4-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -0
- data/README.txt +51 -0
- data/Rakefile +86 -0
- data/bin/duby +10 -0
- data/bin/dubyc +10 -0
- data/bin/dubyp +10 -0
- data/bin/jrubyp +36 -0
- data/bin/mirah +9 -0
- data/bin/mirah.cmd +1 -0
- data/bin/mirahc +9 -0
- data/bin/mirahc.cmd +1 -0
- data/bin/mirahp +9 -0
- data/bin/mirahp.cmd +1 -0
- data/examples/ant/example-build.xml +7 -0
- data/examples/appengine/Rakefile +19 -0
- data/examples/appengine/Readme +29 -0
- data/examples/appengine/src/org/mirah/MirahApp.mirah +57 -0
- data/examples/appengine/src/org/mirah/list.dhtml +15 -0
- data/examples/appengine/war/WEB-INF/lib/dubydatastore.jar +0 -0
- data/examples/bintrees.mirah +66 -0
- data/examples/construction.mirah +8 -0
- data/examples/dynamic.mirah +17 -0
- data/examples/edb.mirah +3 -0
- data/examples/fib.mirah +16 -0
- data/examples/fields.mirah +22 -0
- data/examples/fractal.mirah +55 -0
- data/examples/java_thing.mirah +13 -0
- data/examples/plugins/appengine/Rakefile +55 -0
- data/examples/plugins/appengine/lib/com/google/appengine/ext/duby/db/datastore.rb +375 -0
- data/examples/plugins/appengine/src/com/google/appengine/ext/duby/db/Model.duby +336 -0
- data/examples/plugins/appengine/test/com/google/appengine/ext/duby/db/ModelTest.duby +113 -0
- data/examples/simple_class.mirah +12 -0
- data/examples/sort_closure.mirah +7 -0
- data/examples/swing.mirah +20 -0
- data/examples/tak.mirah +15 -0
- data/examples/test.edb +9 -0
- data/examples/wiki/Rakefile +18 -0
- data/examples/wiki/src/org/mirah/wiki/MirahWiki.duby +324 -0
- data/examples/wiki/src/org/mirah/wiki/edit.eduby.html +42 -0
- data/examples/wiki/src/org/mirah/wiki/error.eduby.html +2 -0
- data/examples/wiki/src/org/mirah/wiki/layout.eduby.html +69 -0
- data/examples/wiki/src/org/mirah/wiki/parser.eduby.html +7 -0
- data/examples/wiki/src/org/mirah/wiki/view.eduby.html +15 -0
- data/examples/wiki/war/WEB-INF/classes/test/HeredocContext.class +0 -0
- data/examples/wiki/war/WEB-INF/classes/test/MirahParser.class +0 -0
- data/examples/wiki/war/WEB-INF/lib/appengine-api.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/dubydatastore.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/jmeta-runtime.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/pegdown-stubs.jar +0 -0
- data/examples/wiki/war/WEB-INF/pegdown.jar +0 -0
- data/examples/wiki/war/app.yaml +21 -0
- data/examples/wiki/war/public/favicon.ico +0 -0
- data/examples/wiki/war/public/images/appengine_duby.png +0 -0
- data/examples/wiki/war/public/images/back.gif +0 -0
- data/examples/wiki/war/public/images/dir.gif +0 -0
- data/examples/wiki/war/public/images/file.gif +0 -0
- data/examples/wiki/war/public/javascripts/prettify.js +61 -0
- data/examples/wiki/war/public/robots.txt +0 -0
- data/examples/wiki/war/public/stylesheets/main.css +156 -0
- data/examples/wiki/war/public/stylesheets/prettify.css +1 -0
- data/examples/wiki/war/public/stylesheets/sh_style.css +66 -0
- data/examples/wiki/war/public/stylesheets/source.css +21 -0
- data/examples/wiki/war/public/wmd/images/bg-fill.png +0 -0
- data/examples/wiki/war/public/wmd/images/bg.png +0 -0
- data/examples/wiki/war/public/wmd/images/blockquote.png +0 -0
- data/examples/wiki/war/public/wmd/images/bold.png +0 -0
- data/examples/wiki/war/public/wmd/images/code.png +0 -0
- data/examples/wiki/war/public/wmd/images/h1.png +0 -0
- data/examples/wiki/war/public/wmd/images/hr.png +0 -0
- data/examples/wiki/war/public/wmd/images/img.png +0 -0
- data/examples/wiki/war/public/wmd/images/italic.png +0 -0
- data/examples/wiki/war/public/wmd/images/link.png +0 -0
- data/examples/wiki/war/public/wmd/images/ol.png +0 -0
- data/examples/wiki/war/public/wmd/images/redo.png +0 -0
- data/examples/wiki/war/public/wmd/images/separator.png +0 -0
- data/examples/wiki/war/public/wmd/images/ul.png +0 -0
- data/examples/wiki/war/public/wmd/images/undo.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd-on.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd.png +0 -0
- data/examples/wiki/war/public/wmd/showdown.js +421 -0
- data/examples/wiki/war/public/wmd/wmd-base.js +1799 -0
- data/examples/wiki/war/public/wmd/wmd-plus.js +311 -0
- data/examples/wiki/war/public/wmd/wmd.js +73 -0
- data/javalib/JRubyParser.jar +0 -0
- data/javalib/dynalang-invoke-0.1.jar +0 -0
- data/javalib/mirah-bootstrap.jar +0 -0
- data/javalib/mirah-parser.jar +0 -0
- data/lib/duby.rb +2 -0
- data/lib/mirah.rb +338 -0
- data/lib/mirah/appengine_tasks.rb +146 -0
- data/lib/mirah/ast.rb +615 -0
- data/lib/mirah/ast/call.rb +307 -0
- data/lib/mirah/ast/class.rb +311 -0
- data/lib/mirah/ast/flow.rb +364 -0
- data/lib/mirah/ast/intrinsics.rb +470 -0
- data/lib/mirah/ast/literal.rb +154 -0
- data/lib/mirah/ast/local.rb +89 -0
- data/lib/mirah/ast/method.rb +360 -0
- data/lib/mirah/ast/scope.rb +208 -0
- data/lib/mirah/ast/structure.rb +226 -0
- data/lib/mirah/ast/type.rb +130 -0
- data/lib/mirah/compiler.rb +341 -0
- data/lib/mirah/env.rb +33 -0
- data/lib/mirah/jvm/base.rb +258 -0
- data/lib/mirah/jvm/compiler.rb +885 -0
- data/lib/mirah/jvm/method_lookup.rb +203 -0
- data/lib/mirah/jvm/source_compiler.rb +737 -0
- data/lib/mirah/jvm/source_generator/builder.rb +444 -0
- data/lib/mirah/jvm/source_generator/loops.rb +110 -0
- data/lib/mirah/jvm/source_generator/precompile.rb +188 -0
- data/lib/mirah/jvm/source_generator/typer.rb +11 -0
- data/lib/mirah/jvm/typer.rb +151 -0
- data/lib/mirah/jvm/types.rb +416 -0
- data/lib/mirah/jvm/types/basic_types.rb +33 -0
- data/lib/mirah/jvm/types/boolean.rb +17 -0
- data/lib/mirah/jvm/types/enumerable.rb +65 -0
- data/lib/mirah/jvm/types/extensions.rb +86 -0
- data/lib/mirah/jvm/types/factory.rb +186 -0
- data/lib/mirah/jvm/types/floats.rb +86 -0
- data/lib/mirah/jvm/types/integers.rb +171 -0
- data/lib/mirah/jvm/types/intrinsics.rb +376 -0
- data/lib/mirah/jvm/types/literals.rb +74 -0
- data/lib/mirah/jvm/types/methods.rb +614 -0
- data/lib/mirah/jvm/types/number.rb +143 -0
- data/lib/mirah/nbcompiler.rb +29 -0
- data/lib/mirah/plugin/edb.rb +29 -0
- data/lib/mirah/plugin/gwt.rb +173 -0
- data/lib/mirah/plugin/java.rb +55 -0
- data/lib/mirah/transform.rb +266 -0
- data/lib/mirah/transform2.rb +728 -0
- data/lib/mirah/typer.rb +407 -0
- data/lib/mirah_task.rb +107 -0
- data/test/test_ast.rb +359 -0
- data/test/test_compilation.rb +112 -0
- data/test/test_env.rb +42 -0
- data/test/test_gwt.rb +58 -0
- data/test/test_java_typer.rb +183 -0
- data/test/test_javac_compiler.rb +63 -0
- data/test/test_jvm_compiler.rb +2607 -0
- data/test/test_typer.rb +221 -0
- metadata +235 -0
@@ -0,0 +1,336 @@
|
|
1
|
+
import java.util.ConcurrentModificationException
|
2
|
+
|
3
|
+
import com.google.appengine.api.datastore.DatastoreServiceFactory
|
4
|
+
import com.google.appengine.api.datastore.Entity
|
5
|
+
import com.google.appengine.api.datastore.EntityNotFoundException
|
6
|
+
import com.google.appengine.api.datastore.Key
|
7
|
+
import com.google.appengine.api.datastore.KeyFactory
|
8
|
+
import com.google.appengine.api.datastore.Query
|
9
|
+
import 'Builder', 'com.google.appengine.api.datastore.FetchOptions$Builder'
|
10
|
+
import 'FilterOperator', 'com.google.appengine.api.datastore.Query$FilterOperator'
|
11
|
+
import 'SortDirection', 'com.google.appengine.api.datastore.Query$SortDirection'
|
12
|
+
import com.google.appengine.api.datastore.GeoPt
|
13
|
+
import com.google.appengine.api.datastore.IMHandle
|
14
|
+
import com.google.appengine.api.users.User
|
15
|
+
|
16
|
+
import java.util.Arrays
|
17
|
+
import java.util.Date
|
18
|
+
import java.util.HashMap
|
19
|
+
import java.util.List
|
20
|
+
import java.util.Map
|
21
|
+
|
22
|
+
class DQuery
|
23
|
+
def initialize
|
24
|
+
@query = Query.new(kind)
|
25
|
+
end
|
26
|
+
|
27
|
+
def kind
|
28
|
+
"foo"
|
29
|
+
end
|
30
|
+
|
31
|
+
def limit(l:int)
|
32
|
+
returns void
|
33
|
+
if @options
|
34
|
+
@options.limit(l)
|
35
|
+
else
|
36
|
+
@options = Builder.withLimit(l)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def offset(o:int)
|
41
|
+
returns void
|
42
|
+
if @options
|
43
|
+
@options.offset(o)
|
44
|
+
else
|
45
|
+
@options = Builder.withOffset(o)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def sort(name:String, descending=false):void
|
50
|
+
if descending
|
51
|
+
@query.addSort(name, _desc)
|
52
|
+
else
|
53
|
+
@query.addSort(name)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def count
|
58
|
+
_prepare.countEntities
|
59
|
+
end
|
60
|
+
|
61
|
+
def _query
|
62
|
+
@query
|
63
|
+
end
|
64
|
+
|
65
|
+
def _options
|
66
|
+
if @options.nil?
|
67
|
+
@options = Builder.withOffset(0)
|
68
|
+
end
|
69
|
+
@options
|
70
|
+
end
|
71
|
+
|
72
|
+
def _prepare
|
73
|
+
Model._datastore.prepare(@query)
|
74
|
+
end
|
75
|
+
|
76
|
+
def _eq_op
|
77
|
+
FilterOperator.valueOf("EQUAL")
|
78
|
+
end
|
79
|
+
|
80
|
+
def _desc
|
81
|
+
SortDirection.valueOf("DESCENDING")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class Model
|
86
|
+
defmacro property(name, type) do
|
87
|
+
# This is a hack to make packaging possible.
|
88
|
+
# Everything's still written in ruby, but we load it out of
|
89
|
+
# the datastore plugin's JAR. So as long as Model is in your CLASSPATH
|
90
|
+
# you don't need any extra arguments to dubyc.
|
91
|
+
code = <<RUBY
|
92
|
+
require 'com/google/appengine/ext/duby/db/datastore.rb'
|
93
|
+
AppEngine::DubyDatastorePlugin.add_property(*arg.to_a)
|
94
|
+
RUBY
|
95
|
+
@mirah.__ruby_eval(code, [name, type, @mirah, @call])
|
96
|
+
end
|
97
|
+
|
98
|
+
def initialize; end
|
99
|
+
|
100
|
+
def initialize(key_name:String)
|
101
|
+
@key_name = key_name
|
102
|
+
end
|
103
|
+
|
104
|
+
def initialize(parent:Model)
|
105
|
+
@parent = parent.key
|
106
|
+
end
|
107
|
+
|
108
|
+
def initialize(parent:Key)
|
109
|
+
@parent = parent
|
110
|
+
end
|
111
|
+
|
112
|
+
def initialize(parent:Model, key_name:String)
|
113
|
+
@parent = parent.key
|
114
|
+
@key_name = key_name
|
115
|
+
end
|
116
|
+
|
117
|
+
def initialize(parent:Key, key_name:String)
|
118
|
+
@parent = parent
|
119
|
+
@key_name = key_name
|
120
|
+
end
|
121
|
+
|
122
|
+
def self._datastore
|
123
|
+
unless @service
|
124
|
+
@service = DatastoreServiceFactory.getDatastoreService
|
125
|
+
end
|
126
|
+
@service
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.delete(key:Key)
|
130
|
+
returns void
|
131
|
+
keys = Key[1]
|
132
|
+
keys[0] = key
|
133
|
+
Model._datastore.delete(keys)
|
134
|
+
end
|
135
|
+
|
136
|
+
def kind
|
137
|
+
getClass.getSimpleName
|
138
|
+
end
|
139
|
+
|
140
|
+
def key
|
141
|
+
if @entity
|
142
|
+
@entity.getKey
|
143
|
+
elsif @key_name
|
144
|
+
if @parent
|
145
|
+
KeyFactory.createKey(@parent, kind, @key_name)
|
146
|
+
else
|
147
|
+
KeyFactory.createKey(kind, @key_name)
|
148
|
+
end
|
149
|
+
else
|
150
|
+
Key(nil)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def save
|
155
|
+
Model._datastore.put(to_entity)
|
156
|
+
end
|
157
|
+
|
158
|
+
def delete
|
159
|
+
returns void
|
160
|
+
Model.delete(key)
|
161
|
+
end
|
162
|
+
|
163
|
+
def to_entity
|
164
|
+
before_save
|
165
|
+
@entity ||= begin
|
166
|
+
if @key_name
|
167
|
+
Entity.new(key)
|
168
|
+
elsif @parent
|
169
|
+
Entity.new(kind, @parent)
|
170
|
+
else
|
171
|
+
Entity.new(kind)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
_save_to(@entity)
|
175
|
+
@entity
|
176
|
+
end
|
177
|
+
|
178
|
+
def properties
|
179
|
+
Map(HashMap.new)
|
180
|
+
end
|
181
|
+
|
182
|
+
def entity=(entity:Entity)
|
183
|
+
@entity = entity
|
184
|
+
end
|
185
|
+
|
186
|
+
def parent
|
187
|
+
@parent
|
188
|
+
end
|
189
|
+
|
190
|
+
def coerce_list(object:Object)
|
191
|
+
if object.kind_of?(List)
|
192
|
+
List(object)
|
193
|
+
elsif object.kind_of?(Object[])
|
194
|
+
Arrays.asList(Object[].cast(object))
|
195
|
+
else
|
196
|
+
raise IllegalArgumentException.new(
|
197
|
+
"Expected List, got #{object} (#{object.getClass.getName})")
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def coerce_long(object:Object)
|
202
|
+
if object.kind_of?(Number)
|
203
|
+
Number(object).longValue
|
204
|
+
elsif object.kind_of?(String)
|
205
|
+
Long.parseLong(String(object))
|
206
|
+
else
|
207
|
+
raise IllegalArgumentException.new(
|
208
|
+
"Expected Long, got #{object} (#{object.getClass.getName})")
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def coerce_int(object:Object)
|
213
|
+
if object.kind_of?(Number)
|
214
|
+
Number(object).intValue
|
215
|
+
elsif object.kind_of?(String)
|
216
|
+
Integer.parseInt(String(object))
|
217
|
+
else
|
218
|
+
raise IllegalArgumentException.new(
|
219
|
+
"Expected Integer, got #{object} (#{object.getClass.getName})")
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def coerce_double(object:Object)
|
224
|
+
if object.kind_of?(Number)
|
225
|
+
Number(object).doubleValue
|
226
|
+
elsif object.kind_of?(String)
|
227
|
+
Double.parseDouble(String(object))
|
228
|
+
else
|
229
|
+
raise IllegalArgumentException.new(
|
230
|
+
"Expected Double, got #{object} (#{object.getClass.getName})")
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def coerce_boolean(object:Object)
|
235
|
+
if object.kind_of?(Boolean)
|
236
|
+
Boolean(object).booleanValue
|
237
|
+
elsif object.kind_of?(String)
|
238
|
+
Boolean.parseBoolean(String(object))
|
239
|
+
else
|
240
|
+
raise IllegalArgumentException.new(
|
241
|
+
"Expected Boolean, got #{object} (#{object.getClass.getName})")
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def coerce_date(object:Object)
|
246
|
+
unless object.kind_of?(Date) || object.nil?
|
247
|
+
raise IllegalArgumentException.new(
|
248
|
+
"Expected Date, got #{object} (#{object.getClass.getName})")
|
249
|
+
end
|
250
|
+
Date(object)
|
251
|
+
end
|
252
|
+
|
253
|
+
def coerce_geopt(object:Object)
|
254
|
+
unless object.kind_of?(GeoPt) || object.nil?
|
255
|
+
raise IllegalArgumentException.new(
|
256
|
+
"Expected GeoPt, got #{object} (#{object.getClass.getName})")
|
257
|
+
end
|
258
|
+
GeoPt(object)
|
259
|
+
end
|
260
|
+
|
261
|
+
def coerce_user(object:Object)
|
262
|
+
unless object.kind_of?(User) || object.nil?
|
263
|
+
raise IllegalArgumentException.new(
|
264
|
+
"Expected User, got #{object} (#{object.getClass.getName})")
|
265
|
+
end
|
266
|
+
User(object)
|
267
|
+
end
|
268
|
+
|
269
|
+
def coerce_imhandle(object:Object)
|
270
|
+
unless object.kind_of?(IMHandle) || object.nil?
|
271
|
+
raise IllegalArgumentException.new(
|
272
|
+
"Expected IMHandle, got #{object} (#{object.getClass.getName})")
|
273
|
+
end
|
274
|
+
IMHandle(object)
|
275
|
+
end
|
276
|
+
|
277
|
+
def coerce_string(object:Object)
|
278
|
+
if object.nil?
|
279
|
+
String(nil)
|
280
|
+
else
|
281
|
+
object.toString
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def coerce_key(object:Object)
|
286
|
+
if object.kind_of?(Key) || object.nil?
|
287
|
+
Key(object)
|
288
|
+
elsif object.kind_of?(String)
|
289
|
+
KeyFactory.stringToKey(String(object))
|
290
|
+
else
|
291
|
+
raise IllegalArgumentException.new(
|
292
|
+
"Expected Key, got #{object} (#{object.getClass.getName})")
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def coerce_bytes(object:Object)
|
297
|
+
if object.kind_of?(byte[]) || object.nil?
|
298
|
+
byte[].cast(object)
|
299
|
+
else
|
300
|
+
raise IllegalArgumentException.new(
|
301
|
+
"Expected byte[], got #{object} (#{object.getClass.getName})")
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
# TODO coerce arrays to lists?
|
306
|
+
|
307
|
+
def before_save; end
|
308
|
+
|
309
|
+
def self.transaction(block:Runnable):void
|
310
|
+
tries = 3
|
311
|
+
while tries > 0
|
312
|
+
begin
|
313
|
+
tries -= 1
|
314
|
+
tx = Model._datastore.beginTransaction
|
315
|
+
begin
|
316
|
+
block.run
|
317
|
+
tx.commit
|
318
|
+
return
|
319
|
+
ensure
|
320
|
+
tx.rollback if tx.isActive
|
321
|
+
end
|
322
|
+
rescue ConcurrentModificationException => ex
|
323
|
+
unless tries > 0
|
324
|
+
raise ex
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
# protected
|
331
|
+
def _save_to(e:Entity):void
|
332
|
+
end
|
333
|
+
|
334
|
+
def _read_from(e:Entity):void
|
335
|
+
end
|
336
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig
|
2
|
+
import com.google.appengine.tools.development.testing.LocalServiceTestConfig
|
3
|
+
import com.google.appengine.tools.development.testing.LocalServiceTestHelper
|
4
|
+
|
5
|
+
import org.junit.After
|
6
|
+
import org.junit.Before
|
7
|
+
import org.junit.Test
|
8
|
+
import org.junit.Assert
|
9
|
+
|
10
|
+
import com.google.appengine.api.datastore.Blob
|
11
|
+
import com.google.appengine.api.datastore.Category
|
12
|
+
import com.google.appengine.api.datastore.Email
|
13
|
+
import com.google.appengine.api.datastore.GeoPt
|
14
|
+
import com.google.appengine.api.datastore.IMHandle
|
15
|
+
import com.google.appengine.api.datastore.Key
|
16
|
+
import com.google.appengine.api.datastore.Link
|
17
|
+
import com.google.appengine.api.datastore.PhoneNumber
|
18
|
+
import com.google.appengine.api.datastore.PostalAddress
|
19
|
+
import com.google.appengine.api.datastore.Rating
|
20
|
+
import com.google.appengine.api.datastore.ShortBlob
|
21
|
+
import com.google.appengine.api.datastore.Text
|
22
|
+
import java.util.Date
|
23
|
+
import java.util.HashMap
|
24
|
+
import java.util.List
|
25
|
+
import java.util.ArrayList
|
26
|
+
import com.google.appengine.api.users.User
|
27
|
+
|
28
|
+
class TestModel < Model
|
29
|
+
property 'date', Date
|
30
|
+
property 'akey', Key
|
31
|
+
property 'blob', Blob
|
32
|
+
property 'shortblob', ShortBlob
|
33
|
+
property 'category', Category
|
34
|
+
property 'email', Email
|
35
|
+
property 'geopt', GeoPt
|
36
|
+
property 'imhandle', IMHandle
|
37
|
+
property 'link', Link
|
38
|
+
property 'phonenumber', PhoneNumber
|
39
|
+
property 'address', PostalAddress
|
40
|
+
property 'rating', Rating
|
41
|
+
property 'text', Text
|
42
|
+
property 'string', String
|
43
|
+
property 'integer', Long
|
44
|
+
property 'afloat', Double
|
45
|
+
property 'user', User
|
46
|
+
property 'list', List
|
47
|
+
end
|
48
|
+
|
49
|
+
class ModelTest
|
50
|
+
include Assert
|
51
|
+
|
52
|
+
def helper
|
53
|
+
@helper ||= begin
|
54
|
+
configs = LocalServiceTestConfig[1]
|
55
|
+
configs[0] = LocalDatastoreServiceTestConfig.new
|
56
|
+
LocalServiceTestHelper.new(configs)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
$Before
|
61
|
+
def setup
|
62
|
+
returns void
|
63
|
+
helper.setUp
|
64
|
+
end
|
65
|
+
|
66
|
+
$After
|
67
|
+
def teardown
|
68
|
+
returns void
|
69
|
+
helper.tearDown
|
70
|
+
end
|
71
|
+
|
72
|
+
$Test
|
73
|
+
def test_get_and_put
|
74
|
+
returns void
|
75
|
+
e = TestModel.new
|
76
|
+
e.string = "Hello"
|
77
|
+
e.save
|
78
|
+
e2 = TestModel.get(e.key)
|
79
|
+
assertEquals("Hello", e2.string)
|
80
|
+
assertEquals(e.key, e2.key)
|
81
|
+
end
|
82
|
+
|
83
|
+
$Test
|
84
|
+
def test_sort
|
85
|
+
returns void
|
86
|
+
# just make sure it compiles
|
87
|
+
TestModel.all.sort('link').run
|
88
|
+
end
|
89
|
+
|
90
|
+
$Test
|
91
|
+
def test_properties
|
92
|
+
returns void
|
93
|
+
e = TestModel.new
|
94
|
+
e.string = "Hi"
|
95
|
+
e.rating = 10
|
96
|
+
properties = e.properties
|
97
|
+
assertEquals("Hi", properties.get("string"))
|
98
|
+
assertEquals(Integer.valueOf(10), properties.get("rating"))
|
99
|
+
assertTrue(properties.containsKey("blob"))
|
100
|
+
assertEquals(nil, properties.get("blob"))
|
101
|
+
end
|
102
|
+
|
103
|
+
$Test
|
104
|
+
def test_query_list
|
105
|
+
returns void
|
106
|
+
e = TestModel.new
|
107
|
+
e.list = ["a", "b", "c"]
|
108
|
+
e.save
|
109
|
+
e2 = TestModel.all.list("b").first
|
110
|
+
assertEquals(e.key, e2.key)
|
111
|
+
end
|
112
|
+
# TODO more tests.
|
113
|
+
end
|