sibilant 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -4
- data/js/sibilant/.gitignore +4 -0
- data/js/sibilant/.travis.yml +6 -0
- data/js/sibilant/LICENSE +20 -0
- data/js/sibilant/README.md +70 -0
- data/js/sibilant/bin/sibilant +3 -0
- data/js/sibilant/cli-help +79 -0
- data/js/sibilant/include/functional.sibilant +57 -0
- data/js/sibilant/include/macros.sibilant +374 -0
- data/js/sibilant/include/node.sibilant +2 -0
- data/js/sibilant/lib/browser.js +685 -0
- data/js/sibilant/lib/cli.js +153 -0
- data/js/sibilant/lib/options.js +232 -0
- data/js/sibilant/lib/repl.js +78 -0
- data/js/sibilant/lib/sibilant.js +688 -0
- data/js/sibilant/misc/sibilant-mode.el +129 -0
- data/js/sibilant/package.json +19 -0
- data/js/sibilant/package.sibilant +16 -0
- data/js/sibilant/public/index.html +502 -0
- data/js/sibilant/public/javascripts/browser.js +685 -0
- data/js/sibilant/public/javascripts/jquery-ui.js +392 -0
- data/js/sibilant/public/javascripts/jquery.js +154 -0
- data/js/sibilant/public/javascripts/macros.sibilant +374 -0
- data/js/sibilant/public/javascripts/sibilant.info.sibilant +77 -0
- data/js/sibilant/public/sass/_mixins.sass +98 -0
- data/js/sibilant/public/sass/sibilant.sass +156 -0
- data/js/sibilant/public/stylesheets/Anonymous_Pro-webfont.eot +0 -0
- data/js/sibilant/public/stylesheets/Anonymous_Pro-webfont.svg +241 -0
- data/js/sibilant/public/stylesheets/Anonymous_Pro-webfont.ttf +0 -0
- data/js/sibilant/public/stylesheets/Anonymous_Pro-webfont.woff +0 -0
- data/js/sibilant/public/stylesheets/sibilant.css +166 -0
- data/js/sibilant/src/browser.sibilant +45 -0
- data/js/sibilant/src/cli.sibilant +93 -0
- data/js/sibilant/src/core.sibilant +338 -0
- data/js/sibilant/src/options.sibilant +65 -0
- data/js/sibilant/src/repl.sibilant +59 -0
- data/js/sibilant/src/sibilant.sibilant +78 -0
- data/js/sibilant/test/defvar.sibilant +5 -0
- data/js/sibilant/test/includeFile1.sibilant +1 -0
- data/js/sibilant/test/includeFile2.sibilant +1 -0
- data/js/sibilant/test/node.sibilant +10 -0
- data/js/sibilant/test/slice.sibilant +3 -0
- data/js/sibilant/test/test.sibilant +464 -0
- data/js/sibilant/test/testHelper.sibilant +80 -0
- data/lib/sibilant/version.rb +1 -1
- data/sibilant.gemspec +3 -1
- metadata +44 -1
@@ -0,0 +1,464 @@
|
|
1
|
+
#!/usr/bin/env sibilant -x
|
2
|
+
(include "./testHelper.sibilant")
|
3
|
+
|
4
|
+
(assert-translation "5" "5")
|
5
|
+
(assert-translation "1,000,000.01" "1000000.01")
|
6
|
+
(assert-translation "1,000.00" "1000")
|
7
|
+
(assert-translation "$" "$")
|
8
|
+
(assert-translation "-10.2" "-10.2")
|
9
|
+
(assert-translation "hello" "hello")
|
10
|
+
(assert-translation "hi-world" "hiWorld")
|
11
|
+
(assert-translation "(Object.to-string)" "Object.toString();")
|
12
|
+
(assert-translation "1two" "1\ntwo")
|
13
|
+
(assert-translation "t1" "t1")
|
14
|
+
(assert-translation "JSON" "JSON")
|
15
|
+
(assert-translation "time-zone-1" "timeZone1")
|
16
|
+
(assert-translation "'t1" "\"t1\"")
|
17
|
+
(assert-translation "*hello*" "_hello_")
|
18
|
+
(assert-translation "\"this\nstring\"" "\"this\\n\" +\n\"string\"")
|
19
|
+
(assert-translation "hello?" "hello__QUERY")
|
20
|
+
(assert-translation "hello!" "hello__BANG")
|
21
|
+
(assert-translation "-math" "Math")
|
22
|
+
(assert-translation "\"string\"" "\"string\"")
|
23
|
+
(assert-translation "\"\"" "\"\"")
|
24
|
+
(assert-translation "$.make-array" "$.makeArray")
|
25
|
+
(assert-translation "($.make-array 1)" "$.makeArray(1);")
|
26
|
+
|
27
|
+
(assert-translation "(mod 5 2)" "(5 % 2)")
|
28
|
+
(assert-translation "(and a b c-d)" "(a && b && cD)")
|
29
|
+
(assert-translation "(or a b c-d)" "(a || b || cD)")
|
30
|
+
|
31
|
+
(assert-translation "(> a b)" "(a > b)")
|
32
|
+
(assert-translation "(> a b c)" "(a > b && b > c)")
|
33
|
+
(assert-translation "(> a (+ 1 b) c d)"
|
34
|
+
"(a > (1 + b) && (1 + b) > c && c > d)")
|
35
|
+
|
36
|
+
(each (infix) [ ">" "<" ">=" "<=" ]
|
37
|
+
(assert-translation (concat "(" infix " a b c)")
|
38
|
+
(concat "(a " infix " b && b " infix " c)")))
|
39
|
+
|
40
|
+
|
41
|
+
(assert (> 5 3 2 1) "> comparator works")
|
42
|
+
(assert (< 1 2 3 4 5) "< comparator works")
|
43
|
+
(assert (<= 1 2 2 3 3) "<= comparator works")
|
44
|
+
(assert (>= 3 3 2 2 1 1) ">= comparator works")
|
45
|
+
|
46
|
+
(assert-translation-error "(" "Error: unexpected EOF, probably missing a )")
|
47
|
+
(assert-translation-error ")" "Error: unbalanced parens:\n[]")
|
48
|
+
|
49
|
+
;; I'm not entirely sure if this is what makes the most sense.
|
50
|
+
(assert-translation "(!= a b c)" "(a !== b && b !== c)")
|
51
|
+
;; Maybe (!= a b c) should be (a !== b && a !== c)
|
52
|
+
|
53
|
+
|
54
|
+
(assert-translation "/regex/" "/regex/")
|
55
|
+
|
56
|
+
(assert-translation "(regex \"regex\")" "(new RegExp(\"regex\", undefined))")
|
57
|
+
(assert-translation "(regex \"regex\" 'g)" "(new RegExp(\"regex\", \"g\"))")
|
58
|
+
|
59
|
+
(assert-translation "(pow a b)" "Math.pow(a, b)")
|
60
|
+
(assert-translation "(incr x)" "((x)++)")
|
61
|
+
(assert-translation "(decr x)" "((x)--)")
|
62
|
+
|
63
|
+
(assert-translation "'hello" "\"hello\"")
|
64
|
+
(assert-translation "(quote hello)" "\"hello\"")
|
65
|
+
|
66
|
+
(assert-translation "'(hello world)"
|
67
|
+
"[ \"hello\", \"world\" ]")
|
68
|
+
(assert-translation "(quote (a b c))"
|
69
|
+
"[ \"a\", \"b\", \"c\" ]")
|
70
|
+
|
71
|
+
; lists
|
72
|
+
(assert-translation "(list)" "[ ]")
|
73
|
+
|
74
|
+
(assert-translation "(list a b)"
|
75
|
+
"[ a, b ]")
|
76
|
+
|
77
|
+
; hashes
|
78
|
+
(assert-translation "(hash)" "{ }")
|
79
|
+
(assert-translation "(hash a b)"
|
80
|
+
"{ a: b }")
|
81
|
+
(assert-translation "(hash a b c d)"
|
82
|
+
"{\n a: b,\n c: d\n}")
|
83
|
+
|
84
|
+
|
85
|
+
; when
|
86
|
+
(assert-translation "(when a b)"
|
87
|
+
"(function() {
|
88
|
+
if (a) {
|
89
|
+
return b;
|
90
|
+
}
|
91
|
+
})()")
|
92
|
+
|
93
|
+
(assert-translation "(when a b c d)"
|
94
|
+
"(function() {
|
95
|
+
if (a) {
|
96
|
+
b;
|
97
|
+
c;
|
98
|
+
return d;
|
99
|
+
}
|
100
|
+
})()")
|
101
|
+
|
102
|
+
|
103
|
+
; if
|
104
|
+
|
105
|
+
(assert-translation "(if a b c)"
|
106
|
+
"(function() {
|
107
|
+
if (a) {
|
108
|
+
return b;
|
109
|
+
} else {
|
110
|
+
return c;
|
111
|
+
}
|
112
|
+
})()")
|
113
|
+
|
114
|
+
; progn
|
115
|
+
|
116
|
+
(assert-translation "(progn a b c d e)"
|
117
|
+
"a;\nb;\nc;\nd;\nreturn e;")
|
118
|
+
|
119
|
+
|
120
|
+
; join
|
121
|
+
|
122
|
+
(assert-translation "(join \" \" (list a b c))"
|
123
|
+
"([ a, b, c ]).join(\" \")")
|
124
|
+
|
125
|
+
; meta
|
126
|
+
|
127
|
+
(assert-translation "(meta (+ 5 2))" "7")
|
128
|
+
|
129
|
+
; comment
|
130
|
+
|
131
|
+
(assert-translation "(comment hello)" "// hello")
|
132
|
+
|
133
|
+
(assert-translation "(comment (lambda () hello))"
|
134
|
+
(concat "// (function() {\n"
|
135
|
+
"// return hello;\n"
|
136
|
+
"// })"))
|
137
|
+
|
138
|
+
; new
|
139
|
+
|
140
|
+
(assert-translation "(new (prototype a b c))" "(new prototype(a, b, c))")
|
141
|
+
|
142
|
+
(assert-translation "(thunk a b c)" "(function() {
|
143
|
+
a;
|
144
|
+
b;
|
145
|
+
return c;
|
146
|
+
})")
|
147
|
+
|
148
|
+
(assert-translation "(keys some-object)" "Object.keys(someObject)")
|
149
|
+
|
150
|
+
(assert-translation "(delete (get foo 'bar))" "delete (foo)[\"bar\"];")
|
151
|
+
|
152
|
+
(assert-translation "(delete (get foo 'bar) bam.bibble)"
|
153
|
+
"delete (foo)[\"bar\"];
|
154
|
+
delete bam.bibble;")
|
155
|
+
|
156
|
+
(assert-translation "(thunk (delete a.b c.d e.f))"
|
157
|
+
"(function() {
|
158
|
+
delete a.b;
|
159
|
+
delete c.d;
|
160
|
+
return delete e.f;
|
161
|
+
})")
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
(assert-translation "(defvar a b c d)" "var a = b,\n c = d;")
|
166
|
+
|
167
|
+
(assert-translation "(function? x)" "typeof(x) === 'function'")
|
168
|
+
|
169
|
+
(assert-translation "(number? x)" "typeof(x) === 'number'")
|
170
|
+
|
171
|
+
(assert-translation "(defun foo.bar (a) (* a 2))" "foo.bar = (function(a) {
|
172
|
+
// a:required
|
173
|
+
return (a * 2);
|
174
|
+
});")
|
175
|
+
|
176
|
+
(assert-translation "(each-key key hash a b c)"
|
177
|
+
"(function() {
|
178
|
+
for (var key in hash) (function() {
|
179
|
+
a;
|
180
|
+
b;
|
181
|
+
return c;
|
182
|
+
})();
|
183
|
+
})();")
|
184
|
+
|
185
|
+
(assert-translation "(lambda (&optional first-arg second-arg) true)" "(function(firstArg, secondArg) {
|
186
|
+
// firstArg:optional secondArg:required
|
187
|
+
if (arguments.length < 2) // if firstArg is missing
|
188
|
+
var secondArg = firstArg, firstArg = undefined;
|
189
|
+
|
190
|
+
return true;
|
191
|
+
})")
|
192
|
+
|
193
|
+
|
194
|
+
(assert-translation "(scoped a b c)"
|
195
|
+
"(function() {
|
196
|
+
a;
|
197
|
+
b;
|
198
|
+
return c;
|
199
|
+
})()")
|
200
|
+
|
201
|
+
(assert-translation "(arguments)" "(Array.prototype.slice.apply(arguments))")
|
202
|
+
|
203
|
+
(assert-translation "(set hash k1 v1 k2 v2)"
|
204
|
+
"(hash)[k1] = v1;
|
205
|
+
(hash)[k2] = v2;")
|
206
|
+
|
207
|
+
(assert-translation "(defhash hash a b c d)"
|
208
|
+
"var hash = {
|
209
|
+
a: b,
|
210
|
+
c: d
|
211
|
+
};")
|
212
|
+
|
213
|
+
(assert-translation "(each (x) arr a b c)"
|
214
|
+
"arr.forEach((function(x) {
|
215
|
+
// x:required
|
216
|
+
a;
|
217
|
+
b;
|
218
|
+
return c;
|
219
|
+
}))")
|
220
|
+
|
221
|
+
(assert-translation "(switch a (q 1))"
|
222
|
+
"(function() {
|
223
|
+
switch(a) {
|
224
|
+
case q:
|
225
|
+
return 1;
|
226
|
+
}
|
227
|
+
})()")
|
228
|
+
|
229
|
+
(assert-translation "(switch a ('q 2))"
|
230
|
+
"(function() {
|
231
|
+
switch(a) {
|
232
|
+
case \"q\":
|
233
|
+
return 2;
|
234
|
+
}
|
235
|
+
})()"
|
236
|
+
)
|
237
|
+
(assert-translation "(switch a ((a b) t))"
|
238
|
+
"(function() {
|
239
|
+
switch(a) {
|
240
|
+
case a:
|
241
|
+
case b:
|
242
|
+
return t;
|
243
|
+
}
|
244
|
+
})()")
|
245
|
+
|
246
|
+
(assert-translation "(switch a ((r 's) l))"
|
247
|
+
"(function() {
|
248
|
+
switch(a) {
|
249
|
+
case r:
|
250
|
+
case \"s\":
|
251
|
+
return l;
|
252
|
+
}
|
253
|
+
})()")
|
254
|
+
|
255
|
+
(assert-translation "(switch 1 ((1 2) 'one))"
|
256
|
+
"(function() {
|
257
|
+
switch(1) {
|
258
|
+
case 1:
|
259
|
+
case 2:
|
260
|
+
return \"one\";
|
261
|
+
}
|
262
|
+
})()")
|
263
|
+
|
264
|
+
(assert-translation "(switch (+ 5 2) ('(u v) (wibble) (foo bar)))"
|
265
|
+
"(function() {
|
266
|
+
switch((5 + 2)) {
|
267
|
+
case \"u\":
|
268
|
+
case \"v\":
|
269
|
+
wibble();
|
270
|
+
return foo(bar);
|
271
|
+
}
|
272
|
+
})()")
|
273
|
+
|
274
|
+
|
275
|
+
(assert-translation "(match? /regexp/ foo)" "foo.match(/regexp/)")
|
276
|
+
|
277
|
+
(assert-translation
|
278
|
+
"(before-include)
|
279
|
+
(include \"./includeFile1\")
|
280
|
+
(after-include-1)
|
281
|
+
(include \"./includeFile2\")
|
282
|
+
(after-include-2)"
|
283
|
+
|
284
|
+
"beforeInclude();
|
285
|
+
|
286
|
+
1
|
287
|
+
|
288
|
+
afterInclude1();
|
289
|
+
|
290
|
+
2
|
291
|
+
|
292
|
+
afterInclude2();")
|
293
|
+
|
294
|
+
(assert-equal 2 (switch 'a ('a 1 2)))
|
295
|
+
(assert-equal 'default (switch 27 ('foo 1) (default 'default)))
|
296
|
+
(assert-equal undefined (switch 10 (1 1)))
|
297
|
+
(assert-equal 'hello (switch (+ 5 2)
|
298
|
+
((1 7) (concat 'he 'llo))
|
299
|
+
(7 "doesn't match because it's second")
|
300
|
+
(default 10)))
|
301
|
+
|
302
|
+
(assert-translation "(thunk (setf a b c d e f))"
|
303
|
+
"(function() {
|
304
|
+
a = b;
|
305
|
+
c = d;
|
306
|
+
return e = f;
|
307
|
+
})")
|
308
|
+
|
309
|
+
(assert-translation "(thunk (set b c d e f))"
|
310
|
+
"(function() {
|
311
|
+
(b)[c] = d;
|
312
|
+
return (b)[e] = f;
|
313
|
+
})")
|
314
|
+
|
315
|
+
|
316
|
+
(assert-translation
|
317
|
+
"(defmacro foo? () 1) (foo?) (delmacro foo?) (foo?)"
|
318
|
+
"1\nfoo__QUERY();")
|
319
|
+
|
320
|
+
(assert-translation
|
321
|
+
"(while (< i 10) (console.log 'here) (alert 'there) 'everywhere)"
|
322
|
+
"(function() {
|
323
|
+
var __returnValue__ = undefined;
|
324
|
+
while ((i < 10)) {
|
325
|
+
__returnValue__ = (function() {
|
326
|
+
console.log(\"here\");
|
327
|
+
alert(\"there\");
|
328
|
+
return \"everywhere\";
|
329
|
+
})();
|
330
|
+
};
|
331
|
+
return __returnValue__;
|
332
|
+
})()")
|
333
|
+
|
334
|
+
|
335
|
+
(scoped
|
336
|
+
(defvar i 0)
|
337
|
+
(defvar return-string
|
338
|
+
(while (< i 10)
|
339
|
+
(setf i (+ i 1))
|
340
|
+
(concat "stopped at iteration: " i)))
|
341
|
+
(assert-equal "stopped at iteration: 10" return-string))
|
342
|
+
|
343
|
+
(assert-translation
|
344
|
+
"(return (progn (return a)))" "return a;")
|
345
|
+
|
346
|
+
(assert-translation
|
347
|
+
"(return (progn (switch a (b c))))"
|
348
|
+
|
349
|
+
"return (function() {
|
350
|
+
switch(a) {
|
351
|
+
case b:
|
352
|
+
return c;
|
353
|
+
}
|
354
|
+
})();")
|
355
|
+
|
356
|
+
(assert-translation "(= a b c)" "
|
357
|
+
(a === b &&
|
358
|
+
a === c)")
|
359
|
+
|
360
|
+
(assert-translation "(progn)" "return undefined;")
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
(assert-translation "{foo : bar wibble : wam }"
|
366
|
+
"{
|
367
|
+
foo: bar,
|
368
|
+
wibble: wam
|
369
|
+
}")
|
370
|
+
|
371
|
+
(assert-translation "[ foo bar (baz) ]"
|
372
|
+
"[ foo, bar, baz() ]")
|
373
|
+
|
374
|
+
(assert-translation "[[] {} baz {q r s [t]}]"
|
375
|
+
"[ [ ], { }, baz, {
|
376
|
+
q: r,
|
377
|
+
s: [ t ]
|
378
|
+
} ]")
|
379
|
+
|
380
|
+
(assert-translation "{ this: is, valid: [\"json\"]}",
|
381
|
+
"{
|
382
|
+
this: is,
|
383
|
+
valid: [ \"json\" ]
|
384
|
+
}")
|
385
|
+
|
386
|
+
|
387
|
+
(assert-translation "(cons a [ b c d ])"
|
388
|
+
"[ a ].concat([ b, c, d ])")
|
389
|
+
|
390
|
+
(assert-deep-equal '(a b c d) (cons 'a '(b c d)))
|
391
|
+
|
392
|
+
(assert-translation "(defmacro -> () 1) (->)" "1")
|
393
|
+
|
394
|
+
(assert-translation "(alias-macro lambda ->) (-> (a) a) (delmacro ->) (-> (a) a)"
|
395
|
+
"(function(a) {
|
396
|
+
// a:required
|
397
|
+
return a;
|
398
|
+
})
|
399
|
+
->(a(), a);")
|
400
|
+
|
401
|
+
(assert-translation
|
402
|
+
"(rename-macro thunk =>) (=> 'hello) (thunk 'world)
|
403
|
+
(rename-macro => thunk) (thunk 'foo) (=> 'bar)"
|
404
|
+
|
405
|
+
"(function() {
|
406
|
+
return \"hello\";
|
407
|
+
})
|
408
|
+
thunk(\"world\");
|
409
|
+
|
410
|
+
(function() {
|
411
|
+
return \"foo\";
|
412
|
+
})
|
413
|
+
=>(\"bar\");")
|
414
|
+
|
415
|
+
|
416
|
+
(assert-translation
|
417
|
+
"(if-else a b c d e (progn (g) h))"
|
418
|
+
"(function() {
|
419
|
+
if (a) {
|
420
|
+
return b;
|
421
|
+
} else if (c) {
|
422
|
+
return d;
|
423
|
+
} else if (e) {
|
424
|
+
g();
|
425
|
+
return h;
|
426
|
+
}
|
427
|
+
})()")
|
428
|
+
|
429
|
+
|
430
|
+
(assert-translation
|
431
|
+
"(if-else a b c d e)"
|
432
|
+
"(function() {
|
433
|
+
if (a) {
|
434
|
+
return b;
|
435
|
+
} else if (c) {
|
436
|
+
return d;
|
437
|
+
} else {
|
438
|
+
return e;
|
439
|
+
}
|
440
|
+
})()")
|
441
|
+
|
442
|
+
(assert-translation
|
443
|
+
"(list? thing)"
|
444
|
+
"(thing) && (thing).constructor.name === \"Array\"")
|
445
|
+
|
446
|
+
(assert-translation
|
447
|
+
"(thunk (setf x 1))"
|
448
|
+
"(function() {
|
449
|
+
return x = 1;
|
450
|
+
})")
|
451
|
+
|
452
|
+
|
453
|
+
; this test is for duplicated semicolons
|
454
|
+
(assert-translation
|
455
|
+
"(when a (progn (setf b c)))"
|
456
|
+
"(function() {
|
457
|
+
if (a) {
|
458
|
+
return b = c;
|
459
|
+
}
|
460
|
+
})()")
|
461
|
+
|
462
|
+
(assert-translation
|
463
|
+
"(defvar a (setf b c))"
|
464
|
+
"var a = b = c;")
|
@@ -0,0 +1,80 @@
|
|
1
|
+
(defvar sibilant (require "../lib/sibilant")
|
2
|
+
sys (require 'sys)
|
3
|
+
inspect sys.inspect
|
4
|
+
passes 0
|
5
|
+
fails 0)
|
6
|
+
|
7
|
+
(set sibilant
|
8
|
+
'dir (meta (macros.quote sibilant.dir)))
|
9
|
+
|
10
|
+
(delmacro inspect)
|
11
|
+
|
12
|
+
(console.log (concat "Testing " (sibilant.version-string)))
|
13
|
+
|
14
|
+
(defun green (&rest args)
|
15
|
+
(concat "\033[32m" (join "" args) "\033[0m"))
|
16
|
+
|
17
|
+
(defun red (&rest args)
|
18
|
+
(concat "\033[31m" (join "" args) "\033[0m"))
|
19
|
+
|
20
|
+
(defun trim (string)
|
21
|
+
(if string (string.trim) ""))
|
22
|
+
|
23
|
+
(defun pass () (incr passes) (sys.print (green ".")))
|
24
|
+
|
25
|
+
(defun fail (&optional message)
|
26
|
+
(incr fails)
|
27
|
+
(sys.print (concat (red "F") "\n" (+ passes fails) ": "
|
28
|
+
(or message "")
|
29
|
+
(chain (get (new (Error)) 'stack)
|
30
|
+
(replace /Error.*/ ""))
|
31
|
+
"\n")))
|
32
|
+
|
33
|
+
(defun assert (thing &optional message)
|
34
|
+
(if thing (pass) (fail message)))
|
35
|
+
|
36
|
+
(defun assert-equal (expected actual &optional message)
|
37
|
+
(assert (= expected actual)
|
38
|
+
(concat (if message (concat message "\n") "")
|
39
|
+
"\n expected " (green (inspect expected))
|
40
|
+
"\n but got " (red (inspect actual)) "\n")))
|
41
|
+
|
42
|
+
(defun assert-match (regex thing &optional message)
|
43
|
+
(assert (regex.test thing)
|
44
|
+
(concat (if message (concat message "\n\n") "")
|
45
|
+
"expected "
|
46
|
+
(inspect thing) " to match "
|
47
|
+
(inspect regex) " but it did not.")))
|
48
|
+
|
49
|
+
(defun assert-translation (sibilant-code js-code)
|
50
|
+
(assert-equal (trim js-code)
|
51
|
+
(trim (try (sibilant.translate-all sibilant-code)))))
|
52
|
+
|
53
|
+
(defun assert-throws (block &optional message)
|
54
|
+
(try (progn (block)
|
55
|
+
(fail (concat "expected to catch "
|
56
|
+
(if message (concat "`" message "'") "an error")
|
57
|
+
" but caught nothing")))
|
58
|
+
(if message
|
59
|
+
(assert-equal (trim message) (trim (e.to-string)))
|
60
|
+
(pass))))
|
61
|
+
|
62
|
+
(defun assert-translation-error (sibilant-code error-text)
|
63
|
+
(assert-throws (thunk (sibilant.translate-all (trim sibilant-code))) error-text))
|
64
|
+
|
65
|
+
(defun assert-true (&rest args)
|
66
|
+
(args.unshift true)
|
67
|
+
(apply assert-equal args))
|
68
|
+
|
69
|
+
(defun assert-false (&rest args)
|
70
|
+
(args.unshift false)
|
71
|
+
(apply assert-equal args))
|
72
|
+
|
73
|
+
(defun assert-deep-equal (expected actual)
|
74
|
+
(each (item index) expected
|
75
|
+
(assert-equal item (get actual index))))
|
76
|
+
|
77
|
+
(process.next-tick (lambda ()
|
78
|
+
(console.log (concat "\n\n" (+ passes fails) " total tests, "
|
79
|
+
(green passes " passed") ", " (red fails " failed")))
|
80
|
+
(when (> fails 0) (process.exit 1))))
|
data/lib/sibilant/version.rb
CHANGED
data/sibilant.gemspec
CHANGED
@@ -13,7 +13,9 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://sibilantjs.info"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.files = `git ls-files`.split($/) +
|
17
|
+
`cd js/sibilant; git ls-files`.split($/).map {|file| "js/sibilant/#{file}"}
|
18
|
+
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
21
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sibilant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -67,6 +67,49 @@ files:
|
|
67
67
|
- spec/sinatra_helper_spec.rb
|
68
68
|
- spec/spec_helper.rb
|
69
69
|
- spec/tilt_helper_spec.rb
|
70
|
+
- js/sibilant/.gitignore
|
71
|
+
- js/sibilant/.travis.yml
|
72
|
+
- js/sibilant/LICENSE
|
73
|
+
- js/sibilant/README.md
|
74
|
+
- js/sibilant/bin/sibilant
|
75
|
+
- js/sibilant/cli-help
|
76
|
+
- js/sibilant/include/functional.sibilant
|
77
|
+
- js/sibilant/include/macros.sibilant
|
78
|
+
- js/sibilant/include/node.sibilant
|
79
|
+
- js/sibilant/lib/browser.js
|
80
|
+
- js/sibilant/lib/cli.js
|
81
|
+
- js/sibilant/lib/options.js
|
82
|
+
- js/sibilant/lib/repl.js
|
83
|
+
- js/sibilant/lib/sibilant.js
|
84
|
+
- js/sibilant/misc/sibilant-mode.el
|
85
|
+
- js/sibilant/package.json
|
86
|
+
- js/sibilant/package.sibilant
|
87
|
+
- js/sibilant/public/index.html
|
88
|
+
- js/sibilant/public/javascripts/browser.js
|
89
|
+
- js/sibilant/public/javascripts/jquery-ui.js
|
90
|
+
- js/sibilant/public/javascripts/jquery.js
|
91
|
+
- js/sibilant/public/javascripts/macros.sibilant
|
92
|
+
- js/sibilant/public/javascripts/sibilant.info.sibilant
|
93
|
+
- js/sibilant/public/sass/_mixins.sass
|
94
|
+
- js/sibilant/public/sass/sibilant.sass
|
95
|
+
- js/sibilant/public/stylesheets/Anonymous_Pro-webfont.eot
|
96
|
+
- js/sibilant/public/stylesheets/Anonymous_Pro-webfont.svg
|
97
|
+
- js/sibilant/public/stylesheets/Anonymous_Pro-webfont.ttf
|
98
|
+
- js/sibilant/public/stylesheets/Anonymous_Pro-webfont.woff
|
99
|
+
- js/sibilant/public/stylesheets/sibilant.css
|
100
|
+
- js/sibilant/src/browser.sibilant
|
101
|
+
- js/sibilant/src/cli.sibilant
|
102
|
+
- js/sibilant/src/core.sibilant
|
103
|
+
- js/sibilant/src/options.sibilant
|
104
|
+
- js/sibilant/src/repl.sibilant
|
105
|
+
- js/sibilant/src/sibilant.sibilant
|
106
|
+
- js/sibilant/test/defvar.sibilant
|
107
|
+
- js/sibilant/test/includeFile1.sibilant
|
108
|
+
- js/sibilant/test/includeFile2.sibilant
|
109
|
+
- js/sibilant/test/node.sibilant
|
110
|
+
- js/sibilant/test/slice.sibilant
|
111
|
+
- js/sibilant/test/test.sibilant
|
112
|
+
- js/sibilant/test/testHelper.sibilant
|
70
113
|
homepage: http://sibilantjs.info
|
71
114
|
licenses:
|
72
115
|
- MIT
|