Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 76 lines (50 sloc) 1.931 kB
2789c34 @ccgus playing with a new parser strategy.
authored
1 var count = 1;
2 var tests = new Array();
3
4 var process = function (a, b) {
5
6 //print("running test " + count);
7
8 a = [JSTPreprocessor preprocessCode:a];
9
10 if (a != b) {
11 NSBeep();
12 print("Failure for test " + count);
13 print(a + "\nshould be equal to:\n" + b);
14 return false;
15 }
16
17 print("Success for test " + count);
18
19 count++;
20
21 return true;
22 }
23
24 var addTest = function (a, b) {
25 tests.push(new Array(a, b));
26 }
27
28 print("Staring preprocessing tests.")
29
30 addTest('print([4 - 5, b]);',
31 'print([4 - 5, b]);');
32
33 addTest('print([a, b]);',
34 'print([a,b]);');
35
36 addTest('[db executeUpdate:"insert into foo values (?, ?, ?)",\n 1, // comment!\n @"Hello",\n [NSDate date]];',
37 'db.executeUpdate_("insert into foo values (?, ?, ?)",1,NSString.stringWithString_("Hello"),NSDate.date());');
38
39 addTest('[db executeUpdate:"insert into foo values (?, ?)", 1, "Hello"];',
40 'db.executeUpdate_("insert into foo values (?, ?)",1,"Hello");');
41
42 addTest('var acorn = [JSTalk application:"Acorn"];',
43 'var acorn = JSTalk.application_("Acorn");');
44
45 addTest('print([]);',
46 'print([]);');
47
48 addTest('[fo doSomething:" a " + [b fun] + " c " in:nil];',
49 'fo.doSomething_in_(" a " + b.fun() + " c ", nil);');
4d1f04c @ccgus one more test.
authored
50
51 addTest('print([NSString stringWithString:@"a"+"b"])',
52 'print(NSString.stringWithString_(NSString.stringWithString_("a")+"b"))');
26f3bde @ccgus Rewrote some of the examples, without using the []'s. I just don't w…
authored
53
2789c34 @ccgus playing with a new parser strategy.
authored
54 addTest('[NSFullUserName() lowercaseString];',
55 'NSFullUserName().lowercaseString();');
56
57
58
59 var stopOnFirstFail = false;
60 var shouldContinue = true;
61 var len = tests.length;
62 var idx = 0;
63 while (shouldContinue && idx < len) {
64 var a = tests[idx][0];
65 var b = tests[idx][1];
66
67 shouldContinue = process(a, b);
68
69 shouldContinue = stopOnFirstFail ? shouldContinue : true;
70
71 idx++;
72 }
73
74 print("Done");
75
76 // what about "foo ? bar : xyz" ? Yea, gotta fix that.
Something went wrong with that request. Please try again.