aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2023-09-01 17:20:03 -0400
committerGitHub <noreply@github.com>2023-09-01 14:20:03 -0700
commit95308988b6f70c04c43015a78c93b3f876da5958 (patch)
treeb04e407539730d027bce6c3e54c295cdde0f2304 /test
parent7f9a2df02bf3fe066788a0cf02803ab26d22c311 (diff)
downloadruby-95308988b6f70c04c43015a78c93b3f876da5958.tar.gz
[YARP] Implement Compiling for And / Or / Operator Write Nodes (#8352)
Diffstat (limited to 'test')
-rw-r--r--test/yarp/compiler_test.rb49
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 #
############################################################################