Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
409541d1
Commit
409541d1
authored
Jun 15, 2013
by
Daniel Bovensiepen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Literal Tests
parent
b55958b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
78 deletions
+101
-78
test/t/literals.rb
test/t/literals.rb
+101
-78
No files found.
test/t/literals.rb
View file @
409541d1
...
@@ -3,34 +3,51 @@
...
@@ -3,34 +3,51 @@
assert
(
'Literals Numerical'
,
'8.7.6.2'
)
do
assert
(
'Literals Numerical'
,
'8.7.6.2'
)
do
# signed and unsigned integer
# signed and unsigned integer
1
==
1
and
-
1
==
-
1
and
+
1
==
+
1
and
assert_equal
1
,
1
# signed and unsigned float
assert_equal
(
-
1
,
-
1
)
1.0
==
1.0
and
-
1.0
==
-
1.0
and
assert_equal
(
+
1
,
+
1
)
# binary
# signed and unsigned float
0b10000000
==
128
and
0
B10000000
==
128
assert_equal
1.0
,
1.0
# octal
assert_equal
(
-
1.0
,
-
1.0
)
0
o10
==
8
and
0
O10
==
8
and
0_10
==
8
# binary
# hex
assert_equal
0b10000000
,
128
0xff
==
255
and
0
Xff
==
255
and
assert_equal
0
B10000000
,
128
# decimal
# octal
0
d999
==
999
and
0
D999
==
999
and
assert_equal
0
o10
,
8
# decimal seperator
assert_equal
0
O10
,
8
10_000_000
==
10000000
and
1_0
==
10
and
assert_equal
0_10
,
8
# integer with exponent
# hex
1e1
==
10.0
and
1e-1
==
0.1
and
1e+1
==
10.0
assert_equal
0xff
,
255
# float with exponent
assert_equal
0
Xff
,
255
1.0e1
==
10.0
and
1.0e-1
==
0.1
and
1.0e+1
==
10.0
# decimal
assert_equal
0
d999
,
999
assert_equal
0
D999
,
999
# decimal seperator
assert_equal
10_000_000
,
10000000
assert_equal
1_0
,
10
# integer with exponent
assert_equal
1e1
,
10.0
assert_equal
1e-1
,
0.1
assert_equal
1e+1
,
10.0
# float with exponent
assert_equal
1.0e1
,
10.0
assert_equal
1.0e-1
,
0.1
assert_equal
1.0e+1
,
10.0
end
end
assert
(
'Literals Strings Single Quoted'
,
'8.7.6.3.2'
)
do
assert
(
'Literals Strings Single Quoted'
,
'8.7.6.3.2'
)
do
'abc'
==
'abc'
and
'\''
==
'\''
and
'\\'
==
'\\'
assert_equal
'abc'
,
'abc'
assert_equal
'\''
,
'\''
assert_equal
'\\'
,
'\\'
end
end
assert
(
'Literals Strings Double Quoted'
,
'8.7.6.3.3'
)
do
assert
(
'Literals Strings Double Quoted'
,
'8.7.6.3.3'
)
do
a
=
"abc"
a
=
"abc"
"abc"
==
"abc"
and
"
\"
"
==
"
\"
"
and
"
\\
"
==
"
\\
"
and
assert_equal
"abc"
,
"abc"
"
#{
a
}
"
==
"abc"
assert_equal
"
\"
"
,
"
\"
"
assert_equal
"
\\
"
,
"
\\
"
assert_equal
"
#{
a
}
"
,
"abc"
end
end
assert
(
'Literals Strings Quoted Non-Expanded'
,
'8.7.6.3.4'
)
do
assert
(
'Literals Strings Quoted Non-Expanded'
,
'8.7.6.3.4'
)
do
...
@@ -42,8 +59,13 @@ assert('Literals Strings Quoted Non-Expanded', '8.7.6.3.4') do
...
@@ -42,8 +59,13 @@ assert('Literals Strings Quoted Non-Expanded', '8.7.6.3.4') do
f
=
%q/ab
\/
c/
f
=
%q/ab
\/
c/
g
=
%q{#{a}}
g
=
%q{#{a}}
a
==
'abc'
and
b
==
'abc'
and
c
==
'abc'
and
d
==
'abc'
and
assert_equal
a
,
'abc'
e
==
'abc'
and
f
==
'ab/c'
and
g
==
'#{a}'
assert_equal
b
,
'abc'
assert_equal
c
,
'abc'
assert_equal
d
,
'abc'
assert_equal
e
,
'abc'
assert_equal
f
,
'ab/c'
assert_equal
g
,
'#{a}'
end
end
assert
(
'Literals Strings Quoted Expanded'
,
'8.7.6.3.5'
)
do
assert
(
'Literals Strings Quoted Expanded'
,
'8.7.6.3.5'
)
do
...
@@ -55,8 +77,13 @@ assert('Literals Strings Quoted Expanded', '8.7.6.3.5') do
...
@@ -55,8 +77,13 @@ assert('Literals Strings Quoted Expanded', '8.7.6.3.5') do
f
=
%Q/ab
\/
c/
f
=
%Q/ab
\/
c/
g
=
%Q{
#{
a
}
}
g
=
%Q{
#{
a
}
}
a
==
'abc'
and
b
==
'abc'
and
c
==
'abc'
and
d
==
'abc'
and
assert_equal
a
,
'abc'
e
==
'abc'
and
f
==
'ab/c'
and
g
==
'abc'
assert_equal
b
,
'abc'
assert_equal
c
,
'abc'
assert_equal
d
,
'abc'
assert_equal
e
,
'abc'
assert_equal
f
,
'ab/c'
assert_equal
g
,
'abc'
end
end
assert
(
'Literals Strings Here documents'
,
'8.7.6.3.6'
)
do
assert
(
'Literals Strings Here documents'
,
'8.7.6.3.6'
)
do
...
@@ -114,18 +141,18 @@ KKK
...
@@ -114,18 +141,18 @@ KKK
z
=
<<
'ZZZ'
z
=
<<
'ZZZ'
ZZZ
ZZZ
a
==
"aaa
\n
"
and
a
ssert_equal
a
,
"aaa
\n
"
b
==
"bbb
\n
"
and
assert_equal
b
,
"bbb
\n
"
c
==
[
"c1
\n
"
,
"c 2
\n
"
,
"c 3
\n
"
]
and
assert_equal
c
,
[
"c1
\n
"
,
"c 2
\n
"
,
"c 3
\n
"
]
d
==
"d3DDD
\n
d
\t\n
DDD
\n\n
"
and
assert_equal
d
,
"d3DDD
\n
d
\t\n
DDD
\n\n
"
e
==
"e
\#
{1+2}EEE
\n
e
\\
t
\n
EEE
\\
n
\n
"
and
assert_equal
e
,
"e
\#
{1+2}EEE
\n
e
\\
t
\n
EEE
\\
n
\n
"
f
==
"F
\n
FFfFFF
\n
F
\n
"
and
assert_equal
f
,
"F
\n
FFfFFF
\n
F
\n
"
g
==
" ggg
\n
"
and
assert_equal
g
,
" ggg
\n
"
h
==
" hhh
\n
"
and
assert_equal
h
,
" hhh
\n
"
i
==
" iii
\n
"
and
assert_equal
i
,
" iii
\n
"
j
==
[
" j1j
\n
"
,
" j2j
\n
"
,
" j
\#
{3}j
\n
"
]
and
assert_equal
j
,
[
" j1j
\n
"
,
" j2j
\n
"
,
" j
\#
{3}j
\n
"
]
k
==
123
and
assert_equal
k
,
123
z
==
""
assert_equal
z
,
""
end
end
assert
(
'Literals Array'
,
'8.7.6.4'
)
do
assert
(
'Literals Array'
,
'8.7.6.4'
)
do
...
@@ -146,15 +173,14 @@ assert('Literals Array', '8.7.6.4') do
...
@@ -146,15 +173,14 @@ assert('Literals Array', '8.7.6.4') do
d
d
x
\y
x
\\
y x
\\\y
)
x
\y
x
\\
y x
\\\y
)
test1
=
(
a
==
[
'abc3def'
,
'}g'
]
and
assert_equal
a
,
[
'abc3def'
,
'}g'
]
b
==
[
'abc'
,
'5'
,
'def'
,
'(g'
]
and
assert_equal
b
,
[
'abc'
,
'5'
,
'def'
,
'(g'
]
c
==
[
'7'
]
and
assert_equal
c
,
[
'7'
]
d
==
[
'9'
]
and
assert_equal
d
,
[
'9'
]
e
==
[]
and
assert_equal
e
,
[]
f
==
[
'[ab'
,
'cd][ef]'
]
and
assert_equal
f
,
[
'[ab'
,
'cd][ef]'
]
g
==
[
'ab'
,
'-11'
,
'22'
]
and
assert_equal
g
,
[
'ab'
,
'-11'
,
'22'
]
h
==
[
"a
\n
b"
,
'test abc'
,
"c
\n
d"
,
"xy"
,
"x
\\
y"
,
"x
\\
y"
]
assert_equal
h
,
[
"a
\n
b"
,
'test abc'
,
"c
\n
d"
,
"xy"
,
"x
\\
y"
,
"x
\\
y"
]
)
a
=
%w{abc#{1+2}def
\}
g}
a
=
%w{abc#{1+2}def
\}
g}
b
=
%w(abc #{2+3} def
\(
g)
b
=
%w(abc #{2+3} def
\(
g)
...
@@ -173,17 +199,14 @@ d
...
@@ -173,17 +199,14 @@ d
d
d
x\y x
\\
y x
\\
\y)
x\y x
\\
y x
\\
\y)
test2
=
(
a
==
[
'abc#{1+2}def'
,
'}g'
]
and
assert_equal
a
,
[
'abc#{1+2}def'
,
'}g'
]
b
==
[
'abc'
,
'#{2+3}'
,
'def'
,
'(g'
]
and
assert_equal
b
,
[
'abc'
,
'#{2+3}'
,
'def'
,
'(g'
]
c
==
[
'#{3+4}'
]
and
assert_equal
c
,
[
'#{3+4}'
]
d
==
[
'#{4+5}'
]
and
assert_equal
d
,
[
'#{4+5}'
]
e
==
[]
and
assert_equal
e
,
[]
f
==
[
'[ab'
,
'cd][ef]'
]
and
assert_equal
f
,
[
'[ab'
,
'cd][ef]'
]
g
==
[
'ab'
,
'#{-1}1'
,
'2#{2}'
]
and
assert_equal
g
,
[
'ab'
,
'#{-1}1'
,
'2#{2}'
]
h
==
[
"a
\\
nb"
,
"test abc"
,
"c
\n
d"
,
"x
\\
y"
,
"x
\\
y"
,
"x
\\\\
y"
]
assert_equal
h
,
[
"a
\\
nb"
,
"test abc"
,
"c
\n
d"
,
"x
\\
y"
,
"x
\\
y"
,
"x
\\\\
y"
]
)
test1
and
test2
end
end
assert
(
'Literals Array of symbols'
)
do
assert
(
'Literals Array of symbols'
)
do
...
@@ -199,14 +222,13 @@ assert('Literals Array of symbols') do
...
@@ -199,14 +222,13 @@ assert('Literals Array of symbols') do
2
#{
2
}
2
#{
2
}
}
}
test1
=
(
a
==
[
:'abc3def'
,
:'}g'
]
and
assert_equal
a
,
[
:'abc3def'
,
:'}g'
]
b
==
[
:'abc'
,
:'5'
,
:'def'
,
:'(g'
]
and
assert_equal
b
,
[
:'abc'
,
:'5'
,
:'def'
,
:'(g'
]
c
==
[
:'7'
]
and
assert_equal
c
,
[
:'7'
]
d
==
[
:'9'
]
and
assert_equal
d
,
[
:'9'
]
e
==
[]
and
assert_equal
e
,
[]
f
==
[
:'[ab'
,
:'cd][ef]'
]
and
assert_equal
f
,
[
:'[ab'
,
:'cd][ef]'
]
g
==
[
:'ab'
,
:'-11'
,
:'22'
]
assert_equal
g
,
[
:'ab'
,
:'-11'
,
:'22'
]
)
a
=
%i{abc#{1+2}def
\}
g}
a
=
%i{abc#{1+2}def
\}
g}
b
=
%i(abc #{2+3} def
\(
g)
b
=
%i(abc #{2+3} def
\(
g)
...
@@ -220,16 +242,13 @@ assert('Literals Array of symbols') do
...
@@ -220,16 +242,13 @@ assert('Literals Array of symbols') do
2#{2}
2#{2}
}
}
test2
=
(
a
==
[
:'abc#{1+2}def'
,
:'}g'
]
and
assert_equal
a
,
[
:'abc#{1+2}def'
,
:'}g'
]
b
==
[
:'abc'
,
:'#{2+3}'
,
:'def'
,
:'(g'
]
and
assert_equal
b
,
[
:'abc'
,
:'#{2+3}'
,
:'def'
,
:'(g'
]
c
==
[
:'#{3+4}'
]
and
assert_equal
c
,
[
:'#{3+4}'
]
d
==
[
:'#{4+5}'
]
and
assert_equal
d
,
[
:'#{4+5}'
]
e
==
[]
and
assert_equal
e
,
[]
f
==
[
:'[ab'
,
:'cd][ef]'
]
and
assert_equal
f
,
[
:'[ab'
,
:'cd][ef]'
]
g
==
[
:'ab'
,
:'#{-1}1'
,
:'2#{2}'
]
assert_equal
g
,
[
:'ab'
,
:'#{-1}1'
,
:'2#{2}'
]
)
test1
and
test2
end
end
assert
(
'Literals Symbol'
,
'8.7.6.6'
)
do
assert
(
'Literals Symbol'
,
'8.7.6.6'
)
do
...
@@ -255,10 +274,14 @@ qwe]
...
@@ -255,10 +274,14 @@ qwe]
g
=
%s/foo#{1+2}bar/
g
=
%s/foo#{1+2}bar/
h
=
%s{{foo bar}}
h
=
%s{{foo bar}}
a
==
:'asd qwe'
and
b
==
:"foo bar"
and
c
==
:a3b
and
d
==
:asd
and
assert_equal
a
,
:'asd qwe'
e
==
:' foo )'
and
f
==
:"asd [
\n
qwe"
and
g
==
:'foo#{1+2}bar'
and
assert_equal
b
,
:"foo bar"
h
==
:'{foo bar}'
assert_equal
c
,
:a3b
assert_equal
d
,
:asd
assert_equal
e
,
:' foo )'
assert_equal
f
,
:"asd [
\n
qwe"
assert_equal
g
,
:'foo#{1+2}bar'
assert_equal
h
,
:'{foo bar}'
end
end
# Not Implemented ATM assert('Literals Regular expression', '8.7.6.5') do
# Not Implemented ATM assert('Literals Regular expression', '8.7.6.5') do
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment