From 95308988b6f70c04c43015a78c93b3f876da5958 Mon Sep 17 00:00:00 2001 From: Jemma Issroff Date: Fri, 1 Sep 2023 17:20:03 -0400 Subject: [YARP] Implement Compiling for And / Or / Operator Write Nodes (#8352) --- test/yarp/compiler_test.rb | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'test/yarp/compiler_test.rb') 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 # ############################################################################ -- cgit v1.2.3