Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > cd14cddf3b3ceaf1193157472227757a > files > 633

parrot-doc-1.6.0-1mdv2010.0.i586.rpm

# single non-negative integer
1                       1\n             positive int 1
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
-0                      0\n             negative 0
-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             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             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             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             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             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
;                       ''              one semicolon
;1                      1\n             semicolon at the begging of line
;;;1                    1\n             more that one semicolon
;;                      ''              only semicolons
1;                      1\n             semicolon at end of line
1;;                     1\n             more than one semicolon at the end
1;  ; ; ;;              1\n             more than one semicolon at end of line with ws
1; 2                    1\n2\n          two expressions separated by a semicolon
1;;;;; ;  ; 2           1\n2\n          two expressions separated by a semicolon and ws
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

# newlines
1\n1+1\n1+1+1           1\n2\n3         TODO parse error with newlines and new grammar

# named expressions
a                       0\n             uninitialized a
a;b;c                   0\n0\n0\n       more uninitialized vars
a;a=1;a                 0\n1\n          assign number to lexical
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\n1\n          simple increment
++k;k                   1\n1\n          pre-increment
k++;k                   0\n1\n          post-increment
--k;k                   -1\n-1\n        pre-decrement
k--;k                   0\n-1\n         post-decrement
a;a=1;a;++a;a           0\n1\n2\n2\n    increment test
a;a=1;1;--a;a           0\n1\n0\n0\n    decrement test

# pow
1^1                     1\n             simple pow
2^2                     4\n             another simple pow
2^2^2                   16\n            two pows
2^2+1                   5\n             pow precedence
2^(2+1)                 8\n             pow precedence

# strictly less
1<1                     0\n             false less
1<2                     1\n             true less
2<1                     0\n             false less
1+1<2+2                 1\n             precedence with plus

# less than or equal
1<=1                    1\n             true less or equal
1<=2                    1\n             true less or equal
2<=1                    0\n             false less or equal
1+1<=1+1                1\n             precedence with plus

# strictly greater
1>1                     0\n             false greater
1>2                     0\n             false greater
2>1                     1\n             true greater
2+2>1+1                 1\n             precedence with plus

# greater than or equal
1>=1                    1\n             true greater or equal
1>=2                    0\n             false greater or equal
2>=1                    1\n             true greater or equal
1+1<=1+1                1\n              precedence with plus

# equal and not equal
1==1                    1\n             true equal
1==0                    0\n             false equal
1!=1                    0\n             false not equal
1!=0                    1\n             true not equal

# boolean operators
!1                      0\n             not 1
!-1                     0\n             not negative 1
!0                      1\n             not 0
!0                      1\n             not 0
!!1                     1\n             not not 1
!!9                     1\n             not not 9
!!-1                    1\n             not not negative 1
!!0                     0\n             not not 0
1&&1                    1\n             1 and 1
9&&-1                   1\n             and with other true integers
1&&0                    0\n             1 and 0
0&&1                    0\n             0 and 1
0&&0                    0\n             0 and 0
1||1                    1\n             1 or 1
1||0                    1\n             1 or 0
0||1                    1\n             0 or 1
0||0                    0\n             0 or 0
1&&0||0&&1              0\n             and/or precedence test 1
1||0&&0||1              1\n             and/or precedence test 2

# Strings
"basic calculator"      basic calculator   string
"123456789"             123456789          string with digits only
"abc 123456789"         abc 123456789      string with digits and letters
"first\nsecond"         first\nsecond      string with a newline