# New Ticket Created by Stuart Jansen
# Please include the string: [perl #49578]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=49578 >
Lolcode if (O RLY?) statements start with a bare statement. As a result,
the variable IT should be set to the value of the first if test.
---
CREDITS | 3 +
languages/lolcode/src/parser/actions.pm | 5 ++
languages/lolcode/t/03-if.t | 112 ++++++++++++++++++++++++++++++-
3 files changed, 119 insertions(+), 1 deletions(-)
diff --git a/CREDITS b/CREDITS
index 5783ec3..1d9d88c 100644
--- a/CREDITS
+++ b/CREDITS
@@ -589,6 +589,9 @@ S: Winterthur, Switzerland
N: Stig Brautaset
D: Patch to repair 'make clean'
+N: Stuart Jansen
+D: lolcode patches
+
N: Thilo Planz
D: partcl tests and inspiration
diff --git a/languages/lolcode/src/parser/actions.pm b/languages/lolcode/src/parser/actions.pm
index 1878939..48dc0fa 100644
--- a/languages/lolcode/src/parser/actions.pm
+++ b/languages/lolcode/src/parser/actions.pm
@@ -112,6 +112,11 @@ method ifthen($/) {
:node( $/ )
);
}
+ my $it := PAST::Var.new( :name( 'IT' ), :scope('package'), :viviself('Undef'));
+ my $bind := PAST::Op.new( :pasttype('bind'), :node( $/ ) );
+ $bind.push( $it );
+ $bind.push( $expr );
+ my $past := PAST::Stmts.new( $bind, $past, :node( $/ ) );
make $past;
}
diff --git a/languages/lolcode/t/03-if.t b/languages/lolcode/t/03-if.t
index 0219054..a57bba5 100644
--- a/languages/lolcode/t/03-if.t
+++ b/languages/lolcode/t/03-if.t
@@ -1,5 +1,5 @@
HAI 1.2
- VISIBLE "1..3"
+ VISIBLE "1..14"
WIN
O RLY?
@@ -29,4 +29,114 @@ HAI 1.2
VISIBLE "nok 3"
OIC
+ 4
+ O RLY?
+ YA RLY
+ VISIBLE "ok " IT
+ NO WAI
+ VISIBLE "nok 4"
+ OIC
+
+ 0
+ O RLY?
+ YA RLY
+ VISIBLE "nok 5"
+ NO WAI
+ VISIBLE "ok 5"
+ OIC
+
+ "ok 6"
+ O RLY?
+ YA RLY
+ VISIBLE IT
+ NO WAI
+ VISIBLE "nok 6"
+ OIC
+
+ ""
+ O RLY?
+ YA RLY
+ VISIBLE "nok 7"
+ NO WAI
+ VISIBLE "ok " IT "7"
+ OIC
+
+ "ok 8"
+ O RLY?
+ YA RLY
+ VISIBLE IT
+ MEBBE "nok 8"
+ VISIBLE "nok 8"
+ NO WAI
+ VISIBLE "nok 8"
+ OIC
+
+ I HAS A CHEEZBURGER ITZ FAIL
+ CHEEZBURGER
+ O RLY?
+ YA RLY
+ VISIBLE "nok 9"
+ NO WAI
+ VISIBLE "ok 9"
+ OIC
+
+ CHEEZBURGER R "ok 10"
+ CHEEZBURGER
+ O RLY?
+ YA RLY
+ VISIBLE IT
+ NO WAI
+ VISIBLE "nok 10"
+ OIC
+
+ WIN
+ O RLY?
+ YA RLY
+ "ok 11"
+ VISIBLE IT
+ NO WAI
+ "nok 11"
+ VISIBLE IT
+ OIC
+
+ "ok 12"
+
+ IT
+ O RLY?
+ YA RLY
+ VISIBLE IT
+ "ok 13"
+ NO WAI
+ VISIBLE "nok 12"
+ "nok 12"
+ OIC
+
+ IT
+ O RLY?
+ YA RLY
+ VISIBLE IT
+ NO WAI
+ VISIBLE "nok 13"
+ OIC
+
+ FAIL
+ O RLY?
+ YA RLY
+ VISIBLE "nok 14"
+ NO WAI
+ "ok 14"
+ O RLY?
+ YA RLY
+ IT
+ O RLY?
+ YA RLY
+ VISIBLE IT
+ NO WAI
+ VISIBLE "nok 14"
+ OIC
+ NO WAI
+ VISIBLE "nok 14"
+ OIC
+ OIC
+
KTHXBYE