forked from parmanoir/jscocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path50 setValueForKey op.js
65 lines (47 loc) · 2.15 KB
/
50 setValueForKey op.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// obj.key @= value
// -> obj.setValue_forKey_(value, 'key')
//
// Lots of check because op rewriting must account for comments, parens, newlines ...
//
var key, value
@implementation SetValueOpTester : NSObject
- (void)setValue:(id)v forKey:(NSString *)k
{
key = k
value = v
// log(key + '=' + value)
}
@end
var o = [SetValueOpTester instance]
o.key @= 123
if (key != 'key' && value != 123) throw '@= failed (1)'
o.value1 @= ((((2+2))))
if (key != 'value1' && value != 4) throw '@= failed (1)'
o.value1 @= ((((2+2 /* last comment to check */ ))))
if (key != 'value1' && value != 4) throw '@= failed (1)'
o.value1 @= ((((2+2 /* last comment to check */
))))
if (key != 'value1' && value != 4) throw '@= failed (1)'
o.value1 @= (((((((((((((((((((((((((((((((((((((((((((((((((((((((((2+2)))))))))))))))))))))))))))))))))))))))))))))))))))))))))
if (key != 'value1' && value != 4) throw '@= failed (1)'
o. /* comment */ valueA @= 'BBB'
if (key != 'valueA' && value != 'BBB') throw '@= failed (1)'
o. /* comment */ valueA /* aeaz */ @= 'BBB'
if (key != 'valueA' && value != 'BBB') throw '@= failed (1)'
o. valueA /* aeaz */ @= 'BBB'
if (key != 'valueA' && value != 'BBB') throw '@= failed (1)'
o. /* comment */ /* eza */ valueA /* aeaz */ /* eza */ @= 'BBB'
if (key != 'valueA' && value != 'BBB') throw '@= failed (1)'
var a = 7
o.value1 @= 1 + ((((3+a)))) + 4*(a)
if (key != 'value1' && value != (1 + ((((3+a)))) + 4*(a))) throw '@= failed (1)'
o[ /* comment */ 'valueA'] @= 'BBB'
if (key != 'valueA' && value != 'BBB') throw '@= failed (1)'
o[ 'valueA' /* comment */ ] @= 'BBB'
if (key != 'valueA' && value != 'BBB') throw '@= failed (1)'
o[ /* comment */ 'va' + function() { return 'lu' }() + /* hep */ 'eA'] @= 'BBB'
if (key != 'valueA' && value != 'BBB') throw '@= failed (1)'
// [[NSPrefset2 blah] doThisAndThatWith1:'hello2'+3+[a b] and2:'world'+[z a:1 b:[k d2] c:3]]['value3'] /* ho */ @= /* hai */ 'hello3' + 'world' + 3/5
// [[NSPrefset2 blah] doThisAndThatWith1:'hello2'+3+[a b] and2:'world'+[z a:1 b:[k d2] c:3]]['value3' + [a b][5]] /* ho */ @= /* hai */ 'hello3' + 'world' + 3/5
o = null