summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorFUKUZAWA-Tadashi <[email protected]>2013-03-12 21:54:17 +0900
committerFUKUZAWA-Tadashi <[email protected]>2013-03-17 21:27:37 +0900
commit44fbfc51849e6bad4f7238ad2fd9724af331cea2 (patch)
tree81a351041f22d32e2e819dd94a5789474d038a7d /test
parent7872bee70013ed0763942f6097ca0a61000fc92a (diff)
downloadmruby-44fbfc51849e6bad4f7238ad2fd9724af331cea2.tar.gz
mruby-44fbfc51849e6bad4f7238ad2fd9724af331cea2.zip
implement literal %W %w %s
refactor string parsing
Diffstat (limited to 'test')
-rw-r--r--test/t/literals.rb73
1 files changed, 71 insertions, 2 deletions
diff --git a/test/t/literals.rb b/test/t/literals.rb
index 9a6d341d4..eb3190a07 100644
--- a/test/t/literals.rb
+++ b/test/t/literals.rb
@@ -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