# New Ticket Created by  Nuno Carvalho 
# Please include the string:  [perl #40939]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40939 >


Hiya parrot people,

This patch cleans up (mostly descriptions) and demonstrates the use of
the languages abc test harness. This file is intended to concentrate
the basic tests for the abc language.

Files affected:
languages/abc/t/abc_basic

Best regards,
./smash

PS, most ot this tests where taken from the languages/bc test suit,
thanks to all who wrote them.
Index: languages/abc/t/abc_basic
===================================================================
--- languages/abc/t/abc_basic	(revision 15658)
+++ languages/abc/t/abc_basic	(working copy)
@@ -3,9 +3,11 @@
 0                       0\n             zero
 2                       2\n             positive int
 12345678                12345678\n      another positive int
+
 # single negative integer
 -1                      -1\n            negative one
 -12345678               -12345678\n     another negative int
+
 # positive and negative Integers
 -1                      -1\n            unary -
 0                       0\n             0 without sign
@@ -13,47 +15,58 @@
 -10                     -10\n           another negative int
 0001                    1\n             int with pad
 -0001                   -1\n            negative int with pad
+
 # floats
 .1 + 1                  1.1\n           float with leading dot
 -1.0001                 -1.0001\n       negative float
 1.2                     1.2\n           positive float
 1.2*2-2.0+3             3.4\n           float operation
+
 # binary plus
 1+2                     3\n             two summands
 1+2+3                   6\n             three summands
 1+0+3                   4\n             three summands including 0
 1+2+3+4+5+6+7+8+9+10    55\n            ten summands
 -1+10                   9\n             negative int in expression
+
 # binary minus
-2-1                     1\n             XXX
-1-1                     0\n             XXX
-1-2                     -1\n            XXX
--1- -2                  1\n             XXX
--1+ -2- -4+10           11\n            XXX
--1- -6+3-2              6\n             XXX
+2-1                     1\n             subtraction with two operands
+1-1                     0\n             subtraction with two operands
+1-2                     -1\n            subtraction with two operands
+-1- -2                  1\n             subtraction with two operands
+-1+ -2- -4+10           11\n            subtraction with four operands
+-1- -6+3-2              6\n             subtraction with five operands
+
 # multiplication
-2*2                     4\n             XXX
-2*2*2                   8\n             XXX
+2*2                     4\n             multiplication with two operands
+2*2*2                   8\n             multiplication with three operands
+2*0			0\n             multiplication with zero
+
 # division
-2/2                     1\n             XXX
-2/2/2                   0.5\n           XXX
+2/2                     1\n             division with two operands
+2/2/2                   0.5\n           division with three operands
+0/2			0\n		division with zero (not by zero)
+
 # modulus
-2%2                     0\n             XXX
-3%2                     1\n             XXX
-# precedence of mul, diff, mod
-2/2+.1                  1.1\n           XXX
-2*2+.4                  4.4\n           XXX
-.1-6/2                  -2.9\n          XXX
-2%2+4                   4\n             XXX
+2%2                     0\n             modulus with remainder zero
+3%2                     1\n             modulus with remainder not zero
+
+# precedences
+2/2+.1                  1.1\n           precedence of div
+2*2+.4                  4.4\n           precedence of mul
+.1-6/2                  -2.9\n          precedente of div
+2%2+4                   4\n             precedence of modulus
+
 # parenthesis
 (1)                     1\n             one in parenthesis
-(1+2)-3                 0\n             XXX
--(1+2)-3                -6\n            XXX
-(1+2)-(5+1-2)+7-(8-100)   98\n            XXX
-(1+2)*3                 9\n             XXX
-(1*2)*3                 6\n             XXX
-(1*2)+3                 5\n             XXX
-(1*2)+((((3+4)+5)*6)*7)   506\n         XXX
+(1+2)-3                 0\n             precedence of parenthesis
+-(1+2)-3                -6\n            parenthesis with minus
+(1+2)-(5+1-2)+7-(8-100)   98\n            various parenthesis
+(1+2)*3                 9\n             precedence of parenthesis
+(1*2)*3                 6\n             parenthesis with mul
+(1*2)+3                 5\n             parenthesis with plus
+(1*2)+((((3+4)+5)*6)*7)   506\n         parenthesis within parenthesis
+
 # semicolons
 ;                       \n              one semicolon
 ;1                      1\n             semicolon at the begging of line
@@ -67,6 +80,7 @@
 1+1+1;2+2+2;3+3-1+3+1   3\n6\n9\n       3 additive expression with semicolons
 1+1*1;2+2*2'            2\n6\n          additive and mul expression with semicolons
 3-3/3;4+4%4; 5-5+5      2\n4\n5\n       minus, mul, plus, mod expression
+
 # named expressions
 a                       0\n             uninitialized a
 'a;b;c                  0\n0\n0\n       more uninitialized vars
@@ -74,10 +88,13 @@
 a=11;-a                 -11\n           assign number to lexical
 a;a=1+1;a               0\n2\n          assign number to expression
 a;b;a=4;b=5;c=6;a;b;c   0\n0\n4\n5\n6\n   assign several lexicals
+
 # increment and decrement
-a=a+1;a;a               1\n,1\n         XXX
-++k;                    1\n             XXX
---k;                    -1\n            XXX
-++a;a                   1\n,1\n         XXX
-a;a=1;a;++a;a           0\n1\n2\n2\n    XXX
-a;a=1;1;--a;a           0\n1\n0\n0\n    XXX
+a=a+1;a;a               1\n,1\n         simpre increment
+++k;                    1\n             two left plus sigil increment
+k++;                    1\n             two right plus sigil increment
+--k;                    -1\n            two left minus sigil decrement 
+k--;                    -1\n            two right minus sigil decrement 
+++a;a                   1\n,1\n         two plus sigil increment
+a;a=1;a;++a;a           0\n1\n2\n2\n    imcrement test
+a;a=1;1;--a;a           0\n1\n0\n0\n    decrement test

Reply via email to