diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-22 16:10:28 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-22 16:10:28 +0900 |
| commit | 597149ae23916a5b0ce616565cbbe7bd97142a63 (patch) | |
| tree | 583449aa2d994703b7fc94bf8cbd28a08fff2808 /test/t | |
| parent | b4f9b031deaf7c75dad7aa10f2318bb37e268fa3 (diff) | |
| download | mruby-597149ae23916a5b0ce616565cbbe7bd97142a63.tar.gz mruby-597149ae23916a5b0ce616565cbbe7bd97142a63.zip | |
Change newline style of test/t/lang.rb (from DOS)
Diffstat (limited to 'test/t')
| -rwxr-xr-x | test/t/lang.rb | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/test/t/lang.rb b/test/t/lang.rb index c28bcfa92..4ed1b3daf 100755 --- a/test/t/lang.rb +++ b/test/t/lang.rb @@ -1,74 +1,74 @@ -# The aim of these tests is to detect pitfall for optimized VM.
-
-# Test for or/and
-#
-# You may think instruction fusion(OP_EQ and OP_JMPIF) for avoiding
-# generate intermediate boolean value.
-# But and/or is pitfall for this fusioning.
-#
-# For example, the following mruby code:
-#
-# if i > 0 and i < 10
-#
-# compiles to the following byte code:
-#
-# 1 000 OP_LOADI R1 0 ; R1:i
-# 2 001 OP_MOVE R2 R1 ; R1:i
-# 2 002 OP_LOADI R3 0
-# 2 003 OP_GT R2 :> 1
-# 2 004 OP_JMPNOT R2 008
-# 2 005 OP_MOVE R2 R1 ; R1:i
-# 2 006 OP_LOADI R3 10
-# 2 007 OP_LT R2 :< 1
-# 2 008 OP_JMPNOT R2 (The address of end of then part)
-#
-# When the instruction fusion the OP_GT and OP_JMPNOT you fell into the pitfalls.
-# The deleted intermediate boolean value is used in OP_JMPNOT (address 008).
-
-assert('and', '11.2.3') do
- a = 1
- if a > 0 and a < 10
- b = 1
- else
- b = 0
- end
- assert_equal 1, b
-
- if a < 0 and a < 10
- b = 1
- else
- b = 0
- end
- assert_equal 0, b
-
- if a < 0 and a > 10
- b = 1
- else
- b = 0
- end
- assert_equal 0, b
-end
-
-assert('or','11.2.4') do
- a = 1
- if a > 0 or a < 10
- b = 1
- else
- b = 0
- end
- assert_equal 1, b
-
- if a < 0 or a < 10
- b = 1
- else
- b = 0
- end
- assert_equal 1, b
-
- if a < 0 or a > 10
- b = 1
- else
- b = 0
- end
- assert_equal 0, b
-end
+# The aim of these tests is to detect pitfall for optimized VM. + +# Test for or/and +# +# You may think instruction fusion(OP_EQ and OP_JMPIF) for avoiding +# generate intermediate boolean value. +# But and/or is pitfall for this fusioning. +# +# For example, the following mruby code: +# +# if i > 0 and i < 10 +# +# compiles to the following byte code: +# +# 1 000 OP_LOADI R1 0 ; R1:i +# 2 001 OP_MOVE R2 R1 ; R1:i +# 2 002 OP_LOADI R3 0 +# 2 003 OP_GT R2 :> 1 +# 2 004 OP_JMPNOT R2 008 +# 2 005 OP_MOVE R2 R1 ; R1:i +# 2 006 OP_LOADI R3 10 +# 2 007 OP_LT R2 :< 1 +# 2 008 OP_JMPNOT R2 (The address of end of then part) +# +# When the instruction fusion the OP_GT and OP_JMPNOT you fell into the pitfalls. +# The deleted intermediate boolean value is used in OP_JMPNOT (address 008). + +assert('and', '11.2.3') do + a = 1 + if a > 0 and a < 10 + b = 1 + else + b = 0 + end + assert_equal 1, b + + if a < 0 and a < 10 + b = 1 + else + b = 0 + end + assert_equal 0, b + + if a < 0 and a > 10 + b = 1 + else + b = 0 + end + assert_equal 0, b +end + +assert('or','11.2.4') do + a = 1 + if a > 0 or a < 10 + b = 1 + else + b = 0 + end + assert_equal 1, b + + if a < 0 or a < 10 + b = 1 + else + b = 0 + end + assert_equal 1, b + + if a < 0 or a > 10 + b = 1 + else + b = 0 + end + assert_equal 0, b +end |
