mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
implement literal %W %w %s
refactor string parsing
This commit is contained in:
committed by
Masaki Muranaka
parent
a4c30b93ac
commit
05e735595e
+71
-2
@@ -128,8 +128,77 @@ ZZZ
|
||||
z == ""
|
||||
end
|
||||
|
||||
# Not Implemented ATM assert('Literals Array', '8.7.6.4') do
|
||||
assert('Literals Array', '8.7.6.4') do
|
||||
a = %W{abc#{1+2}def \}g}
|
||||
b = %W(abc #{2+3} def \(g)
|
||||
c = %W[#{3+4}]
|
||||
d = %W< #{4+5} >
|
||||
e = %W//
|
||||
f = %W[[ab cd][ef]]
|
||||
g = %W{
|
||||
ab
|
||||
#{-1}1
|
||||
2#{2}
|
||||
}
|
||||
|
||||
test1 = (a == ['abc3def', '}g'] and
|
||||
b == ['abc', '5', 'def', '(g'] and
|
||||
c == ['7'] and
|
||||
d == ['9'] and
|
||||
e == [] and
|
||||
f == ['[ab', 'cd][ef]'] and
|
||||
g == ['ab', '-11', '22']
|
||||
)
|
||||
|
||||
a = %w{abc#{1+2}def \}g}
|
||||
b = %w(abc #{2+3} def \(g)
|
||||
c = %w[#{3+4}]
|
||||
d = %w< #{4+5} >
|
||||
e = %w//
|
||||
f = %w[[ab cd][ef]]
|
||||
g = %w{
|
||||
ab
|
||||
#{-1}1
|
||||
2#{2}
|
||||
}
|
||||
|
||||
test2 = (a == ['abc#{1+2}def', '}g'] and
|
||||
b == ['abc', '#{2+3}', 'def', '(g'] and
|
||||
c == ['#{3+4}'] and
|
||||
d == ['#{4+5}'] and
|
||||
e == [] and
|
||||
f == ['[ab', 'cd][ef]'] and
|
||||
g == ['ab', '#{-1}1', '2#{2}']
|
||||
)
|
||||
|
||||
test1 and test2
|
||||
end
|
||||
|
||||
assert('Literals Symbol', '8.7.6.6') do
|
||||
/* do not compile error */
|
||||
:$asd
|
||||
:@asd
|
||||
:@@asd
|
||||
:asd=
|
||||
:asd!
|
||||
:asd?
|
||||
:+
|
||||
:+@
|
||||
:if
|
||||
:BEGIN
|
||||
|
||||
a = :"asd qwe"
|
||||
b = :'foo bar'
|
||||
c = :"a#{1+2}b"
|
||||
d = %s(asd)
|
||||
e = %s( foo \))
|
||||
f = %s[asd \[
|
||||
qwe]
|
||||
g = %s/foo#{1+2}bar/
|
||||
|
||||
a == :'asd qwe' and b == :"foo bar" and c == :a3b and d == :asd and
|
||||
e == :' foo )' and f == :"asd [\nqwe" and g == :'foo#{1+2}bar'
|
||||
end
|
||||
|
||||
# Not Implemented ATM assert('Literals Regular expression', '8.7.6.5') do
|
||||
|
||||
# Not Implemented ATM assert('Literals Symbol', '8.7.6.6') do
|
||||
|
||||
Reference in New Issue
Block a user