diff options
author | Jemma Issroff <[email protected]> | 2023-09-01 17:20:03 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2023-09-01 14:20:03 -0700 |
commit | 95308988b6f70c04c43015a78c93b3f876da5958 (patch) | |
tree | b04e407539730d027bce6c3e54c295cdde0f2304 /test/yarp/compiler_test.rb | |
parent | 7f9a2df02bf3fe066788a0cf02803ab26d22c311 (diff) |
[YARP] Implement Compiling for And / Or / Operator Write Nodes (#8352)
Notes
Notes:
Merged-By: jemmaissroff
Diffstat (limited to 'test/yarp/compiler_test.rb')
-rw-r--r-- | test/yarp/compiler_test.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/yarp/compiler_test.rb b/test/yarp/compiler_test.rb index 668908d423..7188defa7f 100644 --- a/test/yarp/compiler_test.rb +++ b/test/yarp/compiler_test.rb @@ -81,6 +81,19 @@ module YARP assert_equal 1, compile("class YARP::CompilerTest; @@yct = 1; end") end + def test_ClassVariableAndWriteNode + assert_equal 1, compile("class YARP::CompilerTest; @@yct = 0; @@yct &&= 1; end") + end + + def test_ClassVariableOrWriteNode + assert_equal 1, compile("class YARP::CompilerTest; @@yct = 1; @@yct ||= 0; end") + assert_equal 1, compile("class YARP::CompilerTest; @@yct = nil; @@yct ||= 1; end") + end + + def test_ClassVariableOperatorWriteNode + assert_equal 1, compile("class YARP::CompilerTest; @@yct = 0; @@yct += 1; end") + end + def test_ConstantWriteNode assert_equal 1, compile("YCT = 1") end @@ -93,14 +106,50 @@ module YARP assert_equal 1, compile("$yct = 1") end + def test_GlobalVariableAndWriteNode + assert_equal 1, compile("$yct = 0; $yct &&= 1") + end + + def test_GlobalVariableOrWriteNode + assert_equal 1, compile("$yct ||= 1") + end + + def test_GlobalVariableOperatorWriteNode + assert_equal 1, compile("$yct = 0; $yct += 1") + end + def test_InstanceVariableWriteNode assert_equal 1, compile("class YARP::CompilerTest; @yct = 1; end") end + def test_InstanceVariableAndWriteNode + assert_equal 1, compile("@yct = 0; @yct &&= 1") + end + + def test_InstanceVariableOrWriteNode + assert_equal 1, compile("@yct ||= 1") + end + + def test_InstanceVariableOperatorWriteNode + assert_equal 1, compile("@yct = 0; @yct += 1") + end + def test_LocalVariableWriteNode assert_equal 1, compile("yct = 1") end + def test_LocalVariableAndWriteNode + assert_equal 1, compile("yct = 0; yct &&= 1") + end + + def test_LocalVariableOrWriteNode + assert_equal 1, compile("yct ||= 1") + end + + def test_LocalVariableOperatorWriteNode + assert_equal 1, compile("yct = 0; yct += 1") + end + ############################################################################ # String-likes # ############################################################################ |