summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-03-18 06:56:26 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2013-03-18 06:56:26 -0700
commit138a3569a29521dc52951787cf09c5d9aac36741 (patch)
treeef9722b6a8666f895755b076c8a866065448337e /test
parenta4c30b93acf931c49d79fb4b0c474dd66fbedcf4 (diff)
parent76c24894a7f859cc76b437a07030f2e2f277eab1 (diff)
downloadmruby-138a3569a29521dc52951787cf09c5d9aac36741.tar.gz
mruby-138a3569a29521dc52951787cf09c5d9aac36741.zip
Merge pull request #1025 from FUKUZAWA-Tadashi/master
implement %W %w %s
Diffstat (limited to 'test')
-rw-r--r--test/t/literals.rb87
1 files changed, 85 insertions, 2 deletions
diff --git a/test/t/literals.rb b/test/t/literals.rb
index 9a6d341d4..5a29cff0c 100644
--- a/test/t/literals.rb
+++ b/test/t/literals.rb
@@ -128,8 +128,91 @@ 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}
+ }
+ h = %W(a\nb
+ test\ abc
+ c\
+d
+ x\y x\\y x\\\y)
+
+ 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'] and
+ h == ["a\nb", 'test abc', "c\nd", "xy", "x\\y", "x\\y"]
+ )
+
+ 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}
+ }
+ h = %w(a\nb
+ test\ abc
+ c\
+d
+ x\y x\\y x\\\y)
+
+ 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}'] and
+ h == ["a\\nb", "test abc", "c\nd", "x\\y", "x\\y", "x\\\\y"]
+ )
+
+ 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/
+ h = %s{{foo 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' and
+ h == :'{foo 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