forked from pannous/english-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash_test.rb
47 lines (40 loc) · 1.58 KB
/
hash_test.rb
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
#!/usr/bin/env ruby
$use_tree=false
$verbose=false
# $verbose=true
require_relative '../parser_test_helper'
class HashTest < ParserBaseTest
include ParserTestHelper
def test_hash_symbol_invariance_extension
a={a:1}
#VIA extension.rb !!! todo : native
assert_equals a[:lhs],a['lhs']
# h=parse '["SuperSecret" : "kSecValueRef"]'
h=parse '{"SuperSecret" : "kSecValueRef"}'
assert_equals h['SuperSecret'],"kSecValueRef"
end
def test_json_data
init('{a{b:"b";c:"c"}}')
@parser.json_hash
end
def test_invariances
assert_result_is '{a:"b"}', a:"b"
# assert_equals parse('{a:"b"}'), a:"b"
end
def test_invariances2 # careful / remove !
assert_equals parse('{a{b:"b",c:"c"}}'),{a:{b:"b",c:"c"}}
assert_equals parse('{a{b:"b";c:"c"}}'), a:{b:"b",c:"c"}
assert_equals parse('{a:"b"}'),parse('{"a":"b"}')
assert_equals parse('{:a => "b"}'), a:'b' #Don't support all of the old rubies syntext
assert_equals parse('{a:{b:"b";c:"c"}}'), a:{b:"b",c:"c"}
# assert_equals parse('{a:{b="b";c="c"}}'), a:{b:"b",c:"c"} # DANGER with properties/setters/data !
# assert_equals parse('a:"b"'), a:"b" # ONLY IN CONTEXT! Special case for arguments
end
def test_immediate_hash
# assert_equals parse('a:{b:"b",c:"c"}'), "a"=>{b:"b",c:"c"} # todo
# assert_equals parse('a:{b:"b";c:"c"}'), a:{b:"b",c:"c"} # No ';' allowed here
assert_equals parse('a{b:"b",c:"c"}'), a:{b:"b",c:"c"} # careful map{puts ":"} !
skip "test_immediate_hash NO, because of blocks!"
assert_equals parse('a:{b:"b",c:"c"}'), a:{b:"b",c:"c"} #
end
end