Anonymous avatar Anonymous committed 798b9a6

Rename 'parrot' tests to 'bootstrap' for clarity.

Comments (0)

Files changed (38)

Lib/test/bootstrap/builtins.py

+#!./parrot pynie.pbc
+# -*- coding: utf-8 -*-
+
+# turn on debug so assert works
+__debug__ = 1     # XXX not valid in real Python.
+
+#len
+print('test: len')
+n = len([1,2,3,4])
+if n == 4: print('success: len')
+else: print('failure: len')
+
+#list
+print('test: list')
+lst1 = [ 1,2,3,4 ]
+lst2 = list(lst1)
+lst1.pop()
+lst1.pop()
+lst1.pop()
+lst1.pop()
+if lst2[2] == 3: print('success: list')
+else: print('failure: list')
+
+#range
+print('test: range')
+lst = list(range(4))
+ok = 0
+n = -1
+for i in lst:
+    n += 1
+    if n == i: ok += 1
+if ok == 4: print('success: range')
+else: print('failure: range')
+
+#str
+print('test: str')
+if str(5) == '5': print('success: str')
+else: print('failure: str')
+
+print('test: len/str')
+if len(str(861)) == 3: print('success: len/str')
+else: print('failure: len/str')
+
+#max
+print('test: max (simple)')
+if max(range(5)) == 4: print('success: max (simple)')
+else: print('failure: max (simple)')
+
+print('test: max (mixed)')
+if max([1,98,3,8,32,8]) == 98: print('success: max (mixed)')
+else: print('failure: max (mixed)')
+
+#min
+print('test: min (simple)')
+if min(range(5)) == 0: print('success: min (simple)')
+else: print('failure: min (simple)')
+
+print('test: min (mixed)')
+if min([98,1,3,8,32,8]) == 1: print('success: min (mixed)')
+else: print('failure: min (mixed)')
+
+#ord
+print('test: ord')
+if ord('a') == 97: print('success: ord')
+else: print('failure: ord')
+
+#pow
+print('test: pow (2 args)')
+if pow(2,3) == 8: print('success: pow (2 args)')
+else: print('failure: pow (2 args)')
+
+print('test: pow (3 args)')
+if pow(2,3,3) == 2: print('success: pow (3 args)')
+else: print('failure: pow (3 args)')
+
+#sum
+print('test: sum')
+if sum(range(5)) == 10: print('success: sum')
+else: print('failure: sum')
+
+#repr
+print('test: repr (int)')
+if repr(5) == '5': print('success: repr (int)')
+else: print('failure: repr (int)')
+
+print('test: repr (string)')
+if repr('hi') == "'hi'": print('success: repr (string)')
+else: print('failure: repr (string)')
+
+print('test: repr (list)')
+a = [ 1, 2, 'hi' ]
+repr_a = "[1, 2, 'hi']"
+if repr(a) == repr_a: print('success: repr (list)')
+else: print('failure: repr (list)')
+
+#map
+print('test: map (builtin func)')
+a = [ 1, 2, 3, 4 ]
+b = [ '1', '2', '3', '4' ]
+res = map(str, a)
+ok = 1
+for i in range(4):
+    if res[i] != b[i]: ok = 0
+if ok: print('success: map (builtin func)')
+else:  print('failure: map (builtin func)')
+
+print('test: map (python func)')
+try:
+    a = [ 1, 2, 3, 4 ]
+    b = [ 2, 3, 4, 5 ]
+    def f(x): return x + 1
+    res = map(f, a)
+    for i in range(4):
+        assert res[i] == b[i]
+    print('success: map (python func)')
+except:
+    print('failure: map (python func)')
+
+#hex
+print('test: hex')
+try:
+    a = [ 0, 5, -256, 1000 ]
+    b = [ '0x0', '0x5', '-0x100', '0x3e8' ]
+    res = map(hex, a)
+    for i in range(4):
+        assert res[i] == b[i]
+    print('success: hex')
+except:
+    print('failure: hex')
+
+#type
+print('test: type')
+try:
+    assert type('foo') is type('yum')
+    assert type('foo') is not type(5)
+    assert type(8) is type(5)
+    print('success: type')
+except:
+    print('failure: type')

Lib/test/bootstrap/class-list.py

+#!./parrot
+
+print('test: len')
+a = [1,2,3]
+if len(a) == 3: print('success: len')
+else: print('failure: len')
+
+print('test: equality')
+a = [0, 1, 2]
+if a == [0, 1, 2] and a != [7, 8, 9]: print('success: equality')
+else: print('failure: equality')
+
+print('test: append')
+a = []
+for i in range(3): a.append(i)
+if a == [0, 1, 2]: print('success: append')
+else: print('failure: append')
+
+print('test: count')
+a = [1,2,5,6,5,5,5,5,6]
+if a.count(5) == 5 and a.count(6) == 2: print('success: count')
+else: print('failure: count')
+
+print('test: extend')
+a = [0, 1, 2]
+b = [7, 8, 9]
+a.extend(b)
+# b should be added to a, but should not be affected
+if a == [0, 1, 2, 7, 8, 9] and b == [7, 8, 9]: print('success: extend')
+else: print('failure: extend')
+
+print('test: index')
+a = [5,8,7]
+# XXX check for ValueError if value doesn't exist
+if a.index(8) == 1: print('success: index')
+else: print('failure: index')
+
+print('test: insert')
+a = [0, 1, 2]
+a.insert(1, 8)
+if a == [0, 8, 1, 2]: print('success: insert')
+else: print('failure: insert')
+
+print('test: pop')
+a = [0, 1, 2]
+i = a.pop()     # pop the 2
+j = a.pop(0)    # pop the 0
+if i == 2 and j == 0: print('success: pop')
+else: print('failure: pop')
+
+print('test: remove')
+a = [5,8,7]
+# XXX check for ValueError if value doesn't exist
+a.remove(8)
+if a == [5, 7]: print('success: remove')
+else: print('failure: remove')
+
+print('test: reverse (empty)')
+a = []
+a.reverse()
+if a == []: print('success: reverse (empty)')
+else: print('failure: reverse (empty)')
+
+print('test: reverse (even element count)')
+a = [1, 2, 3, 4, 5, 6]
+a.reverse()
+if a == [6,5,4,3,2,1]: print('success: reverse (even element count)')
+else: print('failure: reverse (even element count)')
+
+print('test: reverse (odd element count)')
+a = [1, 2, 3, 4, 5]
+a.reverse()
+if a == [5,4,3,2,1]: print('success: reverse (odd element count)')
+else: print('failure: reverse (odd element count)')
+
+print('test: str(list)')
+a = [0, 1, 2]
+if str(a) == '[0, 1, 2]': print('success: str(list)')
+else: print('failure: str(list)')
+
+print('test: repr(list)')
+a = [0, 1, 2]
+if repr(a) == '[0, 1, 2]': print('success: repr(list)')
+else: print('failure: repr(list)')

Lib/test/bootstrap/class-str.py

+#!./parrot
+
+print('test: str.split')
+if 'foobar'.split('o') == [ 'f', '', 'bar' ]:
+    print('success: str.split')
+else:
+    print('failure: str.split')
+
+print('test: str.join')
+if '---'.join(['hello', 'world']) == 'hello---world':
+    print('success: str.join')
+else:
+    print('failure: str.join')

Lib/test/bootstrap/control-flow.py

+#!./parrot pynie.pbc
+
+# if
+
+print('test: if true')
+if 1: print('success: if true')
+else: print('failure: if true')
+
+print('test: if false')
+if 0: print('failure: if false')
+else: print('success: if false')
+
+print('test: elif true')
+if 0: print('failure: elif true')
+elif 1: print('success: elif true')
+
+print('test: elif false')
+if 0: print('failure: elif false')
+elif 0: print('failure: elif false')
+else: print('success: elif false')
+
+# while
+
+i=5
+while i < 7:
+    print('test:', i)
+    print('success:', i)
+    i=i+1
+
+print('test: while count')
+if i == 7: print('success: while count')
+else: print('failure: while count')
+
+print('test: while false')
+while 0:
+    print('failure: while false')
+else:
+    print('success: while false')
+
+# for
+
+print('test: for list literal')
+n = 0
+compare = 1
+for i in [ 1,2,3,4 ]:
+    n += 1
+    if i != n: compare = 0
+if compare: print('success: for list literal')
+else: print('failure: for list literal')
+
+print('test: for list assign')
+lst = [ 1,2,3,4 ]
+n = 0
+compare = 1
+for i in lst:
+    n += 1
+    if i != n: compare = 0
+if compare: print('success: for list assign')
+else: print('failure: for list assign')
+
+print('test: for list bare')
+n = 0
+compare = 1
+for i in 1,2,3,4:
+    n += 1
+    if i != n: compare = 0
+if compare: print('success: for list bare')
+else: print('failure: for list bare')
+
+print('test: nested fors')
+lst = [ ]
+for i in range(3):
+    for j in range(3):
+        lst.append((i + 1) * (j + 1))
+compare = 1
+lst2 = [ 1, 2, 3,  2, 4, 6,  3, 6, 9 ]
+for i in range(9):
+    if lst[i] != lst2[i]: compare = 0
+if compare: print('success: nested fors')
+else: print('failure: nested fors')
+
+print('test: multiple iterators')
+#compare = 0
+#for i, j in ( (0, 0), (1, 2), (2, 4) ):
+#    if j == i * 2: compare += 1
+#if compare == 3: print 'success: multiple iterators'
+#else: print 'failure: multiple iterators'
+print('xfail: multiple iterators [')
+print('multiple iterators not implemented yet')
+print(']')
+
+print('test: nested scopes')
+i = 4
+if 0:
+    if 0: pass
+    i = 2
+if i == 2: print('failure: nested scopes')
+else: print('success: nested scopes')
+
+print('test: for var exists after loop')
+i = 0
+for i in [7,1,3]:
+    pass
+if i == 3: print('success: for var exists after loop')
+else: print('failure: for var exists after loop')

Lib/test/bootstrap/exceptions.py

+#!./parrot pynie.pbc
+
+print('test: catch exception')
+try:
+    x = 1
+    raise Exception
+except:
+    x = 2
+if x == 2: print('success: catch exception')
+else: print('failure: catch exception')
+
+print('test: no exception')
+try:
+    x = 1
+except:
+    x = 2
+if x == 1: print('success: no exception')
+else: print('failure: no exception')
+
+# make sure asserts are on
+# XXX in real Python, you can't set __debug__
+# fix this test so it doesn't either
+
+__debug__ = 1
+
+print('test: assert false')
+try:
+    x = 1
+    assert 0
+except:
+    x = 2
+if x == 2: print('success: assert false')
+else: print('failure: assert false')
+
+print('test: assert true')
+try:
+    x = 1
+    assert 1
+except:
+    x = 2
+if x == 1: print('success: assert true')
+else: print('failure: assert true')
+
+print('test: assert false, no debug')
+__debug__ = 0
+try:
+    x = 1
+    assert 0
+except:
+    x = 2
+if x == 1: print('success: assert false, no debug')
+else: print('failure: assert false, no debug')

Lib/test/bootstrap/functions.py

+#!./parrot pynie.pbc
+# Copyright (C) 2009, Allison Randal
+# Copyright (C) 2009, isop44
+# Copyright (C) 2009, Bradley M. Kuhn <bkuhn@ebb.org>
+
+print('test: define and call a function')
+def x():
+ print("success: define and call a function")
+
+x()
+
+print('test: a function with arguments')
+def y(a,b,c):
+ pass
+
+y(1,2,3)
+print('success: a function with arguments')
+
+print('test: a function with keyword arguments')
+y(1,2,c=3)
+print('success: a function with keyword arguments')
+
+print('test: simple closure with lambda')
+def lambda_closure(n):
+    return lambda: n
+a = lambda_closure(1)
+b = lambda_closure(5)
+if a() == 1 and b() == 5:
+    print('success: simple closure with lambda')
+else:
+    print('failure: simple closure with lambda')
+
+print('test: simple closure with def')
+def def_closure(n):
+    def inner(): return n
+    return inner
+a = def_closure(1)
+b = def_closure(5)
+if a() == 1 and b() == 5:
+    print('success: simple closure with def')
+else:
+    print('failure: simple closure with def')
+
+print('test: lambda inside lambda closure')
+outer = lambda x: lambda: x
+c = outer(12)
+d = outer(22)
+if c() == 12 and d() == 22:
+    print('success: lambda inside lambda closure')
+else:
+    print('failure: lambda inside lambda closure')
+
+

Lib/test/bootstrap/grammar.py

+#!./parrot pynie.pbc
+
+print('test: backslash for line continuation')
+x = 1 \
++ 1
+if x != 2:
+    print('failure: backslash for line continuation [')
+    print("test_grammar.py:9:FAIL test expected 2, not", end=' ')
+    print(x)
+    print("]")
+else: print('success: backslash for line continuation')
+
+print('test: backslash ending comment')
+# Backslash in comments :\
+x = 0
+if x != 0:
+    print('failure: backslash ending comment [')
+    print("test_grammar.py:16:FAIL test expected 0, not", end=' ')
+    print(x)
+    print("]")
+else: print('success: backslash ending comment')
+
+
+print('test: backslash ending comment after space')
+# Backslash in comments \
+x = 2
+if x != 2:
+    print('failure: backslash ending comment after space [')
+    print("test_grammar.py:27:FAIL test expected 2, not", end=' ')
+    print(x)
+    print("]")
+else: print('success: backslash ending comment after space')
+
+
+print('test: hex int')
+if 0xff != 255:
+    print('failure: hex int [')
+    print("test_grammar.py:36:FAIL test expected 255, not", end=' ')
+    print(0xff)
+    print("]")
+else: print('success: hex int')
+
+print('test: octal int')
+if 0o377 != 255:
+    print('failure: octal int [')
+    print("test_grammar.py:44:FAIL test expected 255, not", end=' ')
+    print(0o377)
+    print("]")
+else: print('success: octal int')

Lib/test/bootstrap/listcomps.py

+#!./parrot
+
+
+print('test: simple list comp.')
+a = [ i + 3 for i in range(3) ]
+if a == [ 3, 4, 5 ]: print('success: simple list comp.')
+else: print('failure: simple list comp.')
+
+print('test: list comp. with if')
+a = [ i for i in range(6) if i > 3 ]
+if a == [ 4, 5 ]: print('success: list comp. with if')
+else: print('failure: list comp. with if')
+
+print('test: complex list comp.')
+a = [ (i,10+j) for i in range(3) if i > 0 for j in range(4) if j < 3 if j > 0 ]
+if a == [(1, 11), (1, 12), (2, 11), (2, 12)]:
+    print('success: complex list comp.')
+else:
+    print('failure: complex list comp.')
+
+print('test: nested list comp.')
+a = [ [ i + 2 for i in range(j) ] for j in range(3) ]
+if a == [ [], [2], [2,3] ]:
+    print('success: nested list comp.')
+else:
+    print('failure: nested list comp.')

Lib/test/bootstrap/lists.py

+#!./parrot
+
+
+print('test: one element list')
+a = ["parrot"]
+if a: print('success: one element list')
+else: print('failure: one element list')
+
+print('test: two element list')
+b = ["success: two element list", ["success: subelement"]]
+print(b[0])
+print('test: subelement')
+print(b[1][0])
+
+print('test: single item in parens')
+c = ("success: single item in parens")
+print(c)
+
+print('test: single item with comma')
+d = ("success: single item with comma",)
+print(d[0])

Lib/test/bootstrap/literals.py

+#!./parrot pynie.pbc
+
+# check literals
+
+print('test: integer literals')
+0
+1
+12
+print('success: integer literals')
+
+
+print('test: integer literals with suffix')
+#123l
+#1234L
+print('xfail: integer literals with suffix')
+
+
+print('test: octal literals')
+0o1
+0o2
+0o3
+0o4
+0o5
+0o6
+0o7
+print('success: octal literals')
+
+
+print('test: hex literals')
+0x1
+0x2
+0x3
+0x4
+0x5
+0x6
+0x7
+0x8
+0x9
+0xa
+0xA
+0xb
+0xB
+0xc
+0xC
+0xd
+0xD
+0xe
+0xE
+0xf
+0xF
+0xdeadbeef
+print('success: hex literals')
+
+print('test: floating point literals')
+#3.14
+#10.
+#.001
+#1e100
+#
+#3.14e-10
+#0e0
+#0E0
+#
+print('xfail: floating point literals')
+
+
+print('test:', end=' ')
+print(4)
+print('success:', end=' ')
+print(4)
+
+
+print('test: imaginary literals')
+#3.14j
+#10.j
+#10j
+#.001j
+#1e100j
+#3.14e-10j
+#1J
+print('xfail: imaginary literals')
+
+
+print('test: short string literals')
+'foo" '
+"Foo' "
+'\1\2\3'
+"\4\5\6"
+'\x5'
+print('success: short string literals')
+
+print('test: long string literals')
+#'''foo'''
+#"""foo"""
+#'''\x8'''
+print('xfail: long string literals')

Lib/test/bootstrap/op-assign.py

+#!./parrot pynie.pbc
+
+# check augmented assignment ops
+
+print('test: plus assign')
+i = 0
+i += 10
+if i == 10: print('success: plus assign')
+else: print('failure: plus assign')
+
+print('test: minus assign')
+i = 10
+i -= 5
+if i == 5: print('success: minus assign')
+else: print('failure: minus assign')
+
+print('test: multiply assign')
+i = -5
+i *= 2
+if i == -10: print('success: multiply assign')
+else: print('failure: multiply assign')
+
+print('test: divide assign')
+i = 10
+i /= 2
+if i == 5: print('success: divide assign')
+else: print('failure: divide assign')
+
+print('test: modulus assign')
+i = 10
+i %= 4
+if i == 2: print('success: modulus assign')
+else: print('failure: modulus assign')
+
+print('test: exponent assign')
+#i = 3
+#i **= 3
+#if i == 27: print 'success: exponent assign'
+#else: print 'failure exponent assign'
+print('xfail: exponent assign [')
+print('implement **=')
+print(']')
+
+print('test: right shift assign')
+i = 128
+i >>= 2
+if i == 32: print('success: right shift assign')
+else: print('failure: right shift assign')
+
+print('test: left shift assign')
+i = 1
+i <<= 10
+if i == 1024: print('success: left shift assign')
+else: print('failure: left shift assign')
+
+print('test: bitwise AND assign')
+i = 0x55
+i &= 0x1f
+if i == 0x15: print('success: bitwise AND assign')
+else: print('failure: bitwise AND assign')
+
+print('test: bitwise XOR assign')
+i = 0x55
+i ^= 0x1f
+if i == 0x4a: print('success: bitwise XOR assign')
+else: print('failure: bitwise XOR assign')
+
+print('test: bitwise OR assign')
+i = 0x55
+i |= 0x1f
+if i == 0x5f: print('success: bitwise OR assign')
+else: print('failure: bitwise OR assign')

Lib/test/bootstrap/op-bitwise.py

+#!./parrot pynie.pbc
+
+# &
+
+print('test: 1')
+print('success:', (0 & 0) + 1)
+print('test: 2')
+print('success:', (1 & 0) + 2)
+print('test: 3')
+print('success:', (0 & 1) + 3)
+print('test: 4')
+print('success:', (1 & 1) + 3)
+
+# |
+
+print('test: 5')
+print('success:', (0 | 0) + 5)
+print('test: 6')
+print('success:', (1 | 0) + 5)
+print('test: 7')
+print('success:', (0 | 1) + 6)
+print('test: 8')
+print('success:', (1 | 1) + 7)
+
+# ^
+
+print('test: 9')
+print('success:', (0 ^ 0) + 9)
+print('test: 10')
+print('success:', (1 ^ 0) + 9)
+print('test: 11')
+print('success:', (0 ^ 1) + 10)
+print('test: 12')
+print('success:', (1 ^ 1) + 12)
+
+

Lib/test/bootstrap/op-boolean.py

+#!./parrot pynie.pbc
+
+print('test: logical AND true')
+if 1 and 2 and 3:
+    print('success: logical AND true')
+else:
+    print('failure: logical AND true')
+
+print('test: logical AND false')
+if 0 and 1 and 2:
+    print('failure: logical AND false')
+else:
+    print('success: logical AND false')
+
+print('test: logical OR true')
+if 0 or 1 or 2:
+    print('success: logical OR true')
+else:
+    print('failure: logical OR true')
+
+print('test: logical OR false')
+if 0 or 0 or 0:
+    print('failure: logical OR false')
+else:
+    print('success: logical OR false')
+
+print('test: logical NOT true')
+if not 0:
+    print('success: logical NOT true')
+else:
+    print('failure: logical NOT true')
+
+print('test: logical NOT false')
+if not 1:
+    print('failure: logical NOT false')
+else:
+    print('success: logical NOT false')
+
+print('test: logical OR/AND precedence')
+if 1 or 0 and 0:   # and should be tighter than or
+    print('success: logical OR/AND precedence')
+else:
+    print('failure: logical OR/AND precedence')
+
+print('test: logical ops parentheses')
+if (1 or 0) and 0:   # test parentheses
+    print('failure: logical ops parentheses')
+else:
+    print('success: logical ops parentheses')
+
+print('test: double NOT')
+#if not not 1:
+#   print 'success: double NOT'
+#else:
+#   print 'failure: double NOT'
+print('xfail: double NOT [')
+print('fix double nots')
+print(']')
+
+print('test: conditional expressions')
+if 5 == (5 if 1 else 8) and 8 == (5 if 0 else 8):
+    print('success: conditional expressions')
+else:
+    print('failure: conditional expressions')

Lib/test/bootstrap/op-cmp.py

+#!./parrot pynie.pbc
+
+print('test: 0 less than 1')
+if 0 < 1: print('success: 0 less than 1')
+
+print('test: 1 greater than 0')
+if 1 > 0: print('success: 1 greater than 0')
+
+print('test: 0 less than/equal 1')
+if 0 <= 1: print('success: 0 less than/equal 1')
+
+print('test: 0 less than/equal itself')
+if 0 <= 0: print('success: 0 less than/equal itself')
+
+print('test: 1 greater than/equal 0')
+if 1 >= 0: print('success: 1 greater than/equal 0')
+
+print('test: 0 greater than/equal itself')
+if 0 >= 0: print('success: 0 greater than/equal itself')
+
+print('test: 0 less than 1, less than 2')
+if 0 < 1 < 2: print('success: 0 less than 1, less than 2')
+
+print('test: 2 greater than 1, greater than 0')
+if 2 > 1 > 0: print('success: 2 greater than 1, greater than 0')
+
+print('test: is operator - compare int with self')
+a = 1000
+if a is a:
+    print('success: is operator - compare int with self')
+else:
+    print('failure: is operator - compare int with self')
+
+print('test: is operator - compare 2 ints')
+a = 1000
+b = 1000
+if not (a is b):
+    print('success: is operator - compare 2 ints')
+else:
+    print('failure: is operator - compare 2 ints')
+
+print('test: is not operator - compare int with self')
+a = 1000
+if not (a is not a):
+    print('success: is not operator - compare int with self')
+else:
+    print('failure: is not operator - compare int with self')
+
+print('test: is not operator - compare 2 ints')
+a = 1000
+b = 1000
+if a is not b:
+    print('success: is not operator - compare 2 ints')
+else:
+    print('failure: is not operator - compare 2 ints')

Lib/test/bootstrap/op-logic-compare.py

+#!./parrot pynie.pbc
+
+# &
+
+print('test: boolean logic 0 AND 0')
+x = 0 & 0
+if x == 0: print('success: boolean logic 0 AND 0')
+else:
+    print('failure: boolean logic 0 AND 0 [')
+    print('03-op-logic.py:6:FAIL test expected 0, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: boolean logic 0 AND 1')
+x = 0 & 1
+if x == 0: print('success: boolean logic 0 AND 1')
+else:
+    print('failure: boolean logic 0 AND 1 [')
+    print('03-op-logic.py:15:FAIL test expected 0, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: boolean logic 1 AND 0')
+x = 1 & 0
+if x == 0: print('success: boolean logic 1 AND 0')
+else:
+    print('failure: boolean logic 1 AND 0 [')
+    print('03-op-logic.py:24:FAIL test expected 0, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: boolean logic 1 AND 1')
+x = 1 & 1
+if x == 1: print('success: boolean logic 1 AND 1')
+else:
+    print('failure: boolean logic 1 AND 1 [')
+    print('03-op-logic.py:33:FAIL test expected 1, not', end=' ')
+    print(x)
+    print(']')
+
+# |
+
+print('test: boolean logic 0 OR 0')
+x = 0 | 0
+if x == 0: print('success: boolean logic 0 OR 0')
+else:
+    print('failure: boolean logic 0 OR 0 [')
+    print('03-op-logic.py:6:FAIL test expected 0, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: boolean logic 0 OR 1')
+x = 0 | 1
+if x == 1: print('success: boolean logic 0 OR 1')
+else:
+    print('failure: boolean logic 0 OR 1 [')
+    print('03-op-logic.py:15:FAIL test expected 1, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: boolean logic 1 OR 0')
+x = 1 | 0
+if x == 1: print('success: boolean logic 1 OR 0')
+else:
+    print('failure: boolean logic 1 OR 0 [')
+    print('03-op-logic.py:24:FAIL test expected 1, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: boolean logic 1 OR 1')
+x = 1 | 1
+if x == 1: print('success: boolean logic 1 OR 1')
+else:
+    print('failure: boolean logic 1 OR 1 [')
+    print('03-op-logic.py:33:FAIL test expected 1, not', end=' ')
+    print(x)
+    print(']')

Lib/test/bootstrap/op-math-compare.py

+#!./parrot pynie.pbc
+
+# unary operators
+
+print('test: prefix +')
+x = +7
+if x == 7: print('success: prefix +')
+else:
+    print('failure: prefix + [')
+    print("op-math-compare.py:92:FAIL test expected 7, not", end=' ')
+    print(x)
+    print("]")
+
+print('test: prefix -')
+x = -8
+if x == -8: print('success: prefix -')
+else:
+    print('failure: prefix - [')
+    print("op-math-compare.py:92:FAIL test expected -8, not", end=' ')
+    print(x)
+    print("]")
+
+# basic math operators
+
+print('test: addition')
+x = 1 + 1
+if x == 2: print('success: addition')
+else:
+    print('failure: addition [')
+    print('02-op-math.py:7:FAIL test expected 2, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: addition with zero')
+x = 0 + 1
+if x == 1: print('success: addition with zero')
+else:
+    print('failure: addition with zero [')
+    print('02-op-math.py:16:FAIL test expected 1, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: subtraction')
+x = 4 - 1
+if x == 3: print('success: subtraction')
+else:
+    print('failure: subtraction [')
+    print('02-op-math.py:24:FAIL test expected 3, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: multiplication')
+x = 2 * 2
+if x == 4: print('success: multiplication')
+else:
+    print('failure: multiplication [')
+    print('02-op-math.py:33:FAIL test expected 4, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: division')
+x = 10 / 5
+if x == 2: print('success: division')
+else:
+    print('failure: division [')
+    print('02-op-math.py:42:FAIL test expected 2, not', end=' ')
+    print(x)
+    print(']')
+
+# //, << and >>  operators
+
+print('test: floor division')
+x = 10 // 2
+if x == 5: print('success: floor division')
+else:
+    print('failure: floor division [')
+    print('02-op-math.py:53:FAIL test expected 5, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: floor division and addition')
+x = 0 // 1 + 8
+if x == 8: print('success: floor division and addition')
+else:
+    print('failure: floor division and addition [')
+    print('02-op-math.py:62:FAIL test expected 8, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: left shift')
+x = 3 << 1
+if x == 6: print('success: left shift')
+else:
+    print('failure: left shift [')
+    print('02-op-math.py:71:FAIL test expected 6, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: right shift')
+x = 14 >> 1
+if x == 7: print('success: right shift')
+else:
+    print('failure: right shift [')
+    print('02-op-math.py:80:FAIL test expected 7, not', end=' ')
+    print(x)
+    print(']')
+
+# ** operator
+
+print('test: power')
+x = 3 ** 2
+if x == 9: print('success: power')
+else:
+    print('failure: power [')
+    print('02-op-math.py:91:FAIL test expected 9, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: 0 to the power of 0')
+x = 0 ** 0
+if x == 1: print('success: 0 to the power of 0')
+else:
+    print('failure: 0 to the power of 0 [')
+    print('02-op-math.py:104:FAIL test expected 1, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: 0 to the power of 1')
+x = 0 ** 1
+if x == 0: print('success: 0 to the power of 1')
+else:
+    print('failure: 0 to the power of 1 [')
+    print('02-op-math.py:109:FAIL test expected 0, not', end=' ')
+    print(x)
+    print(']')
+
+print('test: 1 to the power of 0')
+x = 1 ** 0
+if x == 1: print('success: 1 to the power of 0')
+else:
+    print('failure: 1 to the power of 0 [')
+    print('02-op-math.py:118:FAIL test expected 1, not', end=' ')
+    print(x)
+    print(']')
+
+# unary + and -
+print('test: unary plus')
+x = +13
+if x == 13: print('success: unary plus')
+else:
+    print('failure: unary plus [')
+    print('02-op-math.py:128:FAIL test expected 13, not', end=' ')
+    print(x)
+    print(']')
+
+# unary + and -
+print('test: unary minus')
+x = -10 + 24
+if x == 14: print('success: unary minus')
+else:
+    print('failure: unary minus [')
+    print('02-op-math.py:128:FAIL test expected 14, not', end=' ')
+    print(x)
+    print(']')

Lib/test/bootstrap/op-math.py

+#!./parrot pynie.pbc
+
+# basic math operators
+
+print('test: 1')
+print('success:', 0 + 1)
+print('test: 2')
+print('success:', 1 + 1)
+print('test: 3')
+print('success:', 4 - 1)
+print('test: 4')
+print('success:', 2 * 2)
+
+# //, << and >>  operators
+print('test: 5')
+print('success:', 10 // 2)
+print('test: 6')
+print('success:', 3<<1)
+print('test: 7')
+print('success:', 14>>1)
+print('test: 8')
+print('success:', 0 // 1 + 8)
+
+# ** operator
+print('test: 9')
+print('success:', 3**2)
+print('test: 10')
+print('success:', 0**0+9)
+print('test: 11')
+print('success:', 0**1+11)
+print('test: 12')
+print('success:', 1**0+11)
+
+# unary + and -
+print('test: 13')
+print('success:', +13)
+print('test: 14')
+print('success:', -10 + 24)
+print('test: -15')
+print('success:', -15)

Lib/test/bootstrap/simplest.py

+#!./parrot pynie.pbc
+
+print('test: able to print')
+print('success: able to print')

Lib/test/bootstrap/variables.py

+#!./parrot pynie.pbc
+
+print('test: 1')
+i=1
+print('success:', i)
+
+print('test: 2')
+i=i+1
+print('success:', i)
+
+print('test: 3')
+s='3'
+print('success:', s)
+
+print('test: string 4')
+s='string 4'
+print('success:', s)

Lib/test/parrot/builtins.py

-#!./parrot pynie.pbc
-# -*- coding: utf-8 -*-
-
-# turn on debug so assert works
-__debug__ = 1     # XXX not valid in real Python.
-
-#len
-print('test: len')
-n = len([1,2,3,4])
-if n == 4: print('success: len')
-else: print('failure: len')
-
-#list
-print('test: list')
-lst1 = [ 1,2,3,4 ]
-lst2 = list(lst1)
-lst1.pop()
-lst1.pop()
-lst1.pop()
-lst1.pop()
-if lst2[2] == 3: print('success: list')
-else: print('failure: list')
-
-#range
-print('test: range')
-lst = list(range(4))
-ok = 0
-n = -1
-for i in lst:
-    n += 1
-    if n == i: ok += 1
-if ok == 4: print('success: range')
-else: print('failure: range')
-
-#str
-print('test: str')
-if str(5) == '5': print('success: str')
-else: print('failure: str')
-
-print('test: len/str')
-if len(str(861)) == 3: print('success: len/str')
-else: print('failure: len/str')
-
-#max
-print('test: max (simple)')
-if max(range(5)) == 4: print('success: max (simple)')
-else: print('failure: max (simple)')
-
-print('test: max (mixed)')
-if max([1,98,3,8,32,8]) == 98: print('success: max (mixed)')
-else: print('failure: max (mixed)')
-
-#min
-print('test: min (simple)')
-if min(range(5)) == 0: print('success: min (simple)')
-else: print('failure: min (simple)')
-
-print('test: min (mixed)')
-if min([98,1,3,8,32,8]) == 1: print('success: min (mixed)')
-else: print('failure: min (mixed)')
-
-#ord
-print('test: ord')
-if ord('a') == 97: print('success: ord')
-else: print('failure: ord')
-
-#pow
-print('test: pow (2 args)')
-if pow(2,3) == 8: print('success: pow (2 args)')
-else: print('failure: pow (2 args)')
-
-print('test: pow (3 args)')
-if pow(2,3,3) == 2: print('success: pow (3 args)')
-else: print('failure: pow (3 args)')
-
-#sum
-print('test: sum')
-if sum(range(5)) == 10: print('success: sum')
-else: print('failure: sum')
-
-#repr
-print('test: repr (int)')
-if repr(5) == '5': print('success: repr (int)')
-else: print('failure: repr (int)')
-
-print('test: repr (string)')
-if repr('hi') == "'hi'": print('success: repr (string)')
-else: print('failure: repr (string)')
-
-print('test: repr (list)')
-a = [ 1, 2, 'hi' ]
-repr_a = "[1, 2, 'hi']"
-if repr(a) == repr_a: print('success: repr (list)')
-else: print('failure: repr (list)')
-
-#map
-print('test: map (builtin func)')
-a = [ 1, 2, 3, 4 ]
-b = [ '1', '2', '3', '4' ]
-res = map(str, a)
-ok = 1
-for i in range(4):
-    if res[i] != b[i]: ok = 0
-if ok: print('success: map (builtin func)')
-else:  print('failure: map (builtin func)')
-
-print('test: map (python func)')
-try:
-    a = [ 1, 2, 3, 4 ]
-    b = [ 2, 3, 4, 5 ]
-    def f(x): return x + 1
-    res = map(f, a)
-    for i in range(4):
-        assert res[i] == b[i]
-    print('success: map (python func)')
-except:
-    print('failure: map (python func)')
-
-#hex
-print('test: hex')
-try:
-    a = [ 0, 5, -256, 1000 ]
-    b = [ '0x0', '0x5', '-0x100', '0x3e8' ]
-    res = map(hex, a)
-    for i in range(4):
-        assert res[i] == b[i]
-    print('success: hex')
-except:
-    print('failure: hex')
-
-#type
-print('test: type')
-try:
-    assert type('foo') is type('yum')
-    assert type('foo') is not type(5)
-    assert type(8) is type(5)
-    print('success: type')
-except:
-    print('failure: type')

Lib/test/parrot/class-list.py

-#!./parrot
-
-print('test: len')
-a = [1,2,3]
-if len(a) == 3: print('success: len')
-else: print('failure: len')
-
-print('test: equality')
-a = [0, 1, 2]
-if a == [0, 1, 2] and a != [7, 8, 9]: print('success: equality')
-else: print('failure: equality')
-
-print('test: append')
-a = []
-for i in range(3): a.append(i)
-if a == [0, 1, 2]: print('success: append')
-else: print('failure: append')
-
-print('test: count')
-a = [1,2,5,6,5,5,5,5,6]
-if a.count(5) == 5 and a.count(6) == 2: print('success: count')
-else: print('failure: count')
-
-print('test: extend')
-a = [0, 1, 2]
-b = [7, 8, 9]
-a.extend(b)
-# b should be added to a, but should not be affected
-if a == [0, 1, 2, 7, 8, 9] and b == [7, 8, 9]: print('success: extend')
-else: print('failure: extend')
-
-print('test: index')
-a = [5,8,7]
-# XXX check for ValueError if value doesn't exist
-if a.index(8) == 1: print('success: index')
-else: print('failure: index')
-
-print('test: insert')
-a = [0, 1, 2]
-a.insert(1, 8)
-if a == [0, 8, 1, 2]: print('success: insert')
-else: print('failure: insert')
-
-print('test: pop')
-a = [0, 1, 2]
-i = a.pop()     # pop the 2
-j = a.pop(0)    # pop the 0
-if i == 2 and j == 0: print('success: pop')
-else: print('failure: pop')
-
-print('test: remove')
-a = [5,8,7]
-# XXX check for ValueError if value doesn't exist
-a.remove(8)
-if a == [5, 7]: print('success: remove')
-else: print('failure: remove')
-
-print('test: reverse (empty)')
-a = []
-a.reverse()
-if a == []: print('success: reverse (empty)')
-else: print('failure: reverse (empty)')
-
-print('test: reverse (even element count)')
-a = [1, 2, 3, 4, 5, 6]
-a.reverse()
-if a == [6,5,4,3,2,1]: print('success: reverse (even element count)')
-else: print('failure: reverse (even element count)')
-
-print('test: reverse (odd element count)')
-a = [1, 2, 3, 4, 5]
-a.reverse()
-if a == [5,4,3,2,1]: print('success: reverse (odd element count)')
-else: print('failure: reverse (odd element count)')
-
-print('test: str(list)')
-a = [0, 1, 2]
-if str(a) == '[0, 1, 2]': print('success: str(list)')
-else: print('failure: str(list)')
-
-print('test: repr(list)')
-a = [0, 1, 2]
-if repr(a) == '[0, 1, 2]': print('success: repr(list)')
-else: print('failure: repr(list)')

Lib/test/parrot/class-str.py

-#!./parrot
-
-print('test: str.split')
-if 'foobar'.split('o') == [ 'f', '', 'bar' ]:
-    print('success: str.split')
-else:
-    print('failure: str.split')
-
-print('test: str.join')
-if '---'.join(['hello', 'world']) == 'hello---world':
-    print('success: str.join')
-else:
-    print('failure: str.join')

Lib/test/parrot/control-flow.py

-#!./parrot pynie.pbc
-
-# if
-
-print('test: if true')
-if 1: print('success: if true')
-else: print('failure: if true')
-
-print('test: if false')
-if 0: print('failure: if false')
-else: print('success: if false')
-
-print('test: elif true')
-if 0: print('failure: elif true')
-elif 1: print('success: elif true')
-
-print('test: elif false')
-if 0: print('failure: elif false')
-elif 0: print('failure: elif false')
-else: print('success: elif false')
-
-# while
-
-i=5
-while i < 7:
-    print('test:', i)
-    print('success:', i)
-    i=i+1
-
-print('test: while count')
-if i == 7: print('success: while count')
-else: print('failure: while count')
-
-print('test: while false')
-while 0:
-    print('failure: while false')
-else:
-    print('success: while false')
-
-# for
-
-print('test: for list literal')
-n = 0
-compare = 1
-for i in [ 1,2,3,4 ]:
-    n += 1
-    if i != n: compare = 0
-if compare: print('success: for list literal')
-else: print('failure: for list literal')
-
-print('test: for list assign')
-lst = [ 1,2,3,4 ]
-n = 0
-compare = 1
-for i in lst:
-    n += 1
-    if i != n: compare = 0
-if compare: print('success: for list assign')
-else: print('failure: for list assign')
-
-print('test: for list bare')
-n = 0
-compare = 1
-for i in 1,2,3,4:
-    n += 1
-    if i != n: compare = 0
-if compare: print('success: for list bare')
-else: print('failure: for list bare')
-
-print('test: nested fors')
-lst = [ ]
-for i in range(3):
-    for j in range(3):
-        lst.append((i + 1) * (j + 1))
-compare = 1
-lst2 = [ 1, 2, 3,  2, 4, 6,  3, 6, 9 ]
-for i in range(9):
-    if lst[i] != lst2[i]: compare = 0
-if compare: print('success: nested fors')
-else: print('failure: nested fors')
-
-print('test: multiple iterators')
-#compare = 0
-#for i, j in ( (0, 0), (1, 2), (2, 4) ):
-#    if j == i * 2: compare += 1
-#if compare == 3: print 'success: multiple iterators'
-#else: print 'failure: multiple iterators'
-print('xfail: multiple iterators [')
-print('multiple iterators not implemented yet')
-print(']')
-
-print('test: nested scopes')
-i = 4
-if 0:
-    if 0: pass
-    i = 2
-if i == 2: print('failure: nested scopes')
-else: print('success: nested scopes')
-
-print('test: for var exists after loop')
-i = 0
-for i in [7,1,3]:
-    pass
-if i == 3: print('success: for var exists after loop')
-else: print('failure: for var exists after loop')

Lib/test/parrot/exceptions.py

-#!./parrot pynie.pbc
-
-print('test: catch exception')
-try:
-    x = 1
-    raise Exception
-except:
-    x = 2
-if x == 2: print('success: catch exception')
-else: print('failure: catch exception')
-
-print('test: no exception')
-try:
-    x = 1
-except:
-    x = 2
-if x == 1: print('success: no exception')
-else: print('failure: no exception')
-
-# make sure asserts are on
-# XXX in real Python, you can't set __debug__
-# fix this test so it doesn't either
-
-__debug__ = 1
-
-print('test: assert false')
-try:
-    x = 1
-    assert 0
-except:
-    x = 2
-if x == 2: print('success: assert false')
-else: print('failure: assert false')
-
-print('test: assert true')
-try:
-    x = 1
-    assert 1
-except:
-    x = 2
-if x == 1: print('success: assert true')
-else: print('failure: assert true')
-
-print('test: assert false, no debug')
-__debug__ = 0
-try:
-    x = 1
-    assert 0
-except:
-    x = 2
-if x == 1: print('success: assert false, no debug')
-else: print('failure: assert false, no debug')

Lib/test/parrot/functions.py

-#!./parrot pynie.pbc
-# Copyright (C) 2009, Allison Randal
-# Copyright (C) 2009, isop44
-# Copyright (C) 2009, Bradley M. Kuhn <bkuhn@ebb.org>
-
-print('test: define and call a function')
-def x():
- print("success: define and call a function")
-
-x()
-
-print('test: a function with arguments')
-def y(a,b,c):
- pass
-
-y(1,2,3)
-print('success: a function with arguments')
-
-print('test: a function with keyword arguments')
-y(1,2,c=3)
-print('success: a function with keyword arguments')
-
-print('test: simple closure with lambda')
-def lambda_closure(n):
-    return lambda: n
-a = lambda_closure(1)
-b = lambda_closure(5)
-if a() == 1 and b() == 5:
-    print('success: simple closure with lambda')
-else:
-    print('failure: simple closure with lambda')
-
-print('test: simple closure with def')
-def def_closure(n):
-    def inner(): return n
-    return inner
-a = def_closure(1)
-b = def_closure(5)
-if a() == 1 and b() == 5:
-    print('success: simple closure with def')
-else:
-    print('failure: simple closure with def')
-
-print('test: lambda inside lambda closure')
-outer = lambda x: lambda: x
-c = outer(12)
-d = outer(22)
-if c() == 12 and d() == 22:
-    print('success: lambda inside lambda closure')
-else:
-    print('failure: lambda inside lambda closure')
-
-

Lib/test/parrot/grammar.py

-#!./parrot pynie.pbc
-
-print('test: backslash for line continuation')
-x = 1 \
-+ 1
-if x != 2:
-    print('failure: backslash for line continuation [')
-    print("test_grammar.py:9:FAIL test expected 2, not", end=' ')
-    print(x)
-    print("]")
-else: print('success: backslash for line continuation')
-
-print('test: backslash ending comment')
-# Backslash in comments :\
-x = 0
-if x != 0:
-    print('failure: backslash ending comment [')
-    print("test_grammar.py:16:FAIL test expected 0, not", end=' ')
-    print(x)
-    print("]")
-else: print('success: backslash ending comment')
-
-
-print('test: backslash ending comment after space')
-# Backslash in comments \
-x = 2
-if x != 2:
-    print('failure: backslash ending comment after space [')
-    print("test_grammar.py:27:FAIL test expected 2, not", end=' ')
-    print(x)
-    print("]")
-else: print('success: backslash ending comment after space')
-
-
-print('test: hex int')
-if 0xff != 255:
-    print('failure: hex int [')
-    print("test_grammar.py:36:FAIL test expected 255, not", end=' ')
-    print(0xff)
-    print("]")
-else: print('success: hex int')
-
-print('test: octal int')
-if 0o377 != 255:
-    print('failure: octal int [')
-    print("test_grammar.py:44:FAIL test expected 255, not", end=' ')
-    print(0o377)
-    print("]")
-else: print('success: octal int')

Lib/test/parrot/listcomps.py

-#!./parrot
-
-
-print('test: simple list comp.')
-a = [ i + 3 for i in range(3) ]
-if a == [ 3, 4, 5 ]: print('success: simple list comp.')
-else: print('failure: simple list comp.')
-
-print('test: list comp. with if')
-a = [ i for i in range(6) if i > 3 ]
-if a == [ 4, 5 ]: print('success: list comp. with if')
-else: print('failure: list comp. with if')
-
-print('test: complex list comp.')
-a = [ (i,10+j) for i in range(3) if i > 0 for j in range(4) if j < 3 if j > 0 ]
-if a == [(1, 11), (1, 12), (2, 11), (2, 12)]:
-    print('success: complex list comp.')
-else:
-    print('failure: complex list comp.')
-
-print('test: nested list comp.')
-a = [ [ i + 2 for i in range(j) ] for j in range(3) ]
-if a == [ [], [2], [2,3] ]:
-    print('success: nested list comp.')
-else:
-    print('failure: nested list comp.')

Lib/test/parrot/lists.py

-#!./parrot
-
-
-print('test: one element list')
-a = ["parrot"]
-if a: print('success: one element list')
-else: print('failure: one element list')
-
-print('test: two element list')
-b = ["success: two element list", ["success: subelement"]]
-print(b[0])
-print('test: subelement')
-print(b[1][0])
-
-print('test: single item in parens')
-c = ("success: single item in parens")
-print(c)
-
-print('test: single item with comma')
-d = ("success: single item with comma",)
-print(d[0])

Lib/test/parrot/literals.py

-#!./parrot pynie.pbc
-
-# check literals
-
-print('test: integer literals')
-0
-1
-12
-print('success: integer literals')
-
-
-print('test: integer literals with suffix')
-#123l
-#1234L
-print('xfail: integer literals with suffix')
-
-
-print('test: octal literals')
-0o1
-0o2
-0o3
-0o4
-0o5
-0o6
-0o7
-print('success: octal literals')
-
-
-print('test: hex literals')
-0x1
-0x2
-0x3
-0x4
-0x5
-0x6
-0x7
-0x8
-0x9
-0xa
-0xA
-0xb
-0xB
-0xc
-0xC
-0xd
-0xD
-0xe
-0xE
-0xf
-0xF
-0xdeadbeef
-print('success: hex literals')
-
-print('test: floating point literals')
-#3.14
-#10.
-#.001
-#1e100
-#
-#3.14e-10
-#0e0
-#0E0
-#
-print('xfail: floating point literals')
-
-
-print('test:', end=' ')
-print(4)
-print('success:', end=' ')
-print(4)
-
-
-print('test: imaginary literals')
-#3.14j
-#10.j
-#10j
-#.001j
-#1e100j
-#3.14e-10j
-#1J
-print('xfail: imaginary literals')
-
-
-print('test: short string literals')
-'foo" '
-"Foo' "
-'\1\2\3'
-"\4\5\6"
-'\x5'
-print('success: short string literals')
-
-print('test: long string literals')
-#'''foo'''
-#"""foo"""
-#'''\x8'''
-print('xfail: long string literals')

Lib/test/parrot/op-assign.py

-#!./parrot pynie.pbc
-
-# check augmented assignment ops
-
-print('test: plus assign')
-i = 0
-i += 10
-if i == 10: print('success: plus assign')
-else: print('failure: plus assign')
-
-print('test: minus assign')
-i = 10
-i -= 5
-if i == 5: print('success: minus assign')
-else: print('failure: minus assign')
-
-print('test: multiply assign')
-i = -5
-i *= 2
-if i == -10: print('success: multiply assign')
-else: print('failure: multiply assign')
-
-print('test: divide assign')
-i = 10
-i /= 2
-if i == 5: print('success: divide assign')
-else: print('failure: divide assign')
-
-print('test: modulus assign')
-i = 10
-i %= 4
-if i == 2: print('success: modulus assign')
-else: print('failure: modulus assign')
-
-print('test: exponent assign')
-#i = 3
-#i **= 3
-#if i == 27: print 'success: exponent assign'
-#else: print 'failure exponent assign'
-print('xfail: exponent assign [')
-print('implement **=')
-print(']')
-
-print('test: right shift assign')
-i = 128
-i >>= 2
-if i == 32: print('success: right shift assign')
-else: print('failure: right shift assign')
-
-print('test: left shift assign')
-i = 1
-i <<= 10
-if i == 1024: print('success: left shift assign')
-else: print('failure: left shift assign')
-
-print('test: bitwise AND assign')
-i = 0x55
-i &= 0x1f
-if i == 0x15: print('success: bitwise AND assign')
-else: print('failure: bitwise AND assign')
-
-print('test: bitwise XOR assign')
-i = 0x55
-i ^= 0x1f
-if i == 0x4a: print('success: bitwise XOR assign')
-else: print('failure: bitwise XOR assign')
-
-print('test: bitwise OR assign')
-i = 0x55
-i |= 0x1f
-if i == 0x5f: print('success: bitwise OR assign')
-else: print('failure: bitwise OR assign')

Lib/test/parrot/op-bitwise.py

-#!./parrot pynie.pbc
-
-# &
-
-print('test: 1')
-print('success:', (0 & 0) + 1)
-print('test: 2')
-print('success:', (1 & 0) + 2)
-print('test: 3')
-print('success:', (0 & 1) + 3)
-print('test: 4')
-print('success:', (1 & 1) + 3)
-
-# |
-
-print('test: 5')
-print('success:', (0 | 0) + 5)
-print('test: 6')
-print('success:', (1 | 0) + 5)
-print('test: 7')
-print('success:', (0 | 1) + 6)
-print('test: 8')
-print('success:', (1 | 1) + 7)
-
-# ^
-
-print('test: 9')
-print('success:', (0 ^ 0) + 9)
-print('test: 10')
-print('success:', (1 ^ 0) + 9)
-print('test: 11')
-print('success:', (0 ^ 1) + 10)
-print('test: 12')
-print('success:', (1 ^ 1) + 12)
-
-

Lib/test/parrot/op-boolean.py

-#!./parrot pynie.pbc
-
-print('test: logical AND true')
-if 1 and 2 and 3:
-    print('success: logical AND true')
-else:
-    print('failure: logical AND true')
-
-print('test: logical AND false')
-if 0 and 1 and 2:
-    print('failure: logical AND false')
-else:
-    print('success: logical AND false')
-
-print('test: logical OR true')
-if 0 or 1 or 2:
-    print('success: logical OR true')
-else:
-    print('failure: logical OR true')
-
-print('test: logical OR false')
-if 0 or 0 or 0:
-    print('failure: logical OR false')
-else:
-    print('success: logical OR false')
-
-print('test: logical NOT true')
-if not 0:
-    print('success: logical NOT true')
-else:
-    print('failure: logical NOT true')
-
-print('test: logical NOT false')
-if not 1:
-    print('failure: logical NOT false')
-else:
-    print('success: logical NOT false')
-
-print('test: logical OR/AND precedence')
-if 1 or 0 and 0:   # and should be tighter than or
-    print('success: logical OR/AND precedence')
-else:
-    print('failure: logical OR/AND precedence')
-
-print('test: logical ops parentheses')
-if (1 or 0) and 0:   # test parentheses
-    print('failure: logical ops parentheses')
-else:
-    print('success: logical ops parentheses')
-
-print('test: double NOT')
-#if not not 1:
-#   print 'success: double NOT'
-#else:
-#   print 'failure: double NOT'
-print('xfail: double NOT [')
-print('fix double nots')
-print(']')
-
-print('test: conditional expressions')
-if 5 == (5 if 1 else 8) and 8 == (5 if 0 else 8):
-    print('success: conditional expressions')
-else:
-    print('failure: conditional expressions')

Lib/test/parrot/op-cmp.py

-#!./parrot pynie.pbc
-
-print('test: 0 less than 1')
-if 0 < 1: print('success: 0 less than 1')
-
-print('test: 1 greater than 0')
-if 1 > 0: print('success: 1 greater than 0')
-
-print('test: 0 less than/equal 1')
-if 0 <= 1: print('success: 0 less than/equal 1')
-
-print('test: 0 less than/equal itself')
-if 0 <= 0: print('success: 0 less than/equal itself')
-
-print('test: 1 greater than/equal 0')
-if 1 >= 0: print('success: 1 greater than/equal 0')
-
-print('test: 0 greater than/equal itself')
-if 0 >= 0: print('success: 0 greater than/equal itself')
-
-print('test: 0 less than 1, less than 2')
-if 0 < 1 < 2: print('success: 0 less than 1, less than 2')
-
-print('test: 2 greater than 1, greater than 0')
-if 2 > 1 > 0: print('success: 2 greater than 1, greater than 0')
-
-print('test: is operator - compare int with self')
-a = 1000
-if a is a:
-    print('success: is operator - compare int with self')
-else:
-    print('failure: is operator - compare int with self')
-
-print('test: is operator - compare 2 ints')
-a = 1000
-b = 1000
-if not (a is b):
-    print('success: is operator - compare 2 ints')
-else:
-    print('failure: is operator - compare 2 ints')
-
-print('test: is not operator - compare int with self')
-a = 1000
-if not (a is not a):
-    print('success: is not operator - compare int with self')
-else:
-    print('failure: is not operator - compare int with self')
-
-print('test: is not operator - compare 2 ints')
-a = 1000
-b = 1000
-if a is not b:
-    print('success: is not operator - compare 2 ints')
-else:
-    print('failure: is not operator - compare 2 ints')

Lib/test/parrot/op-logic-compare.py

-#!./parrot pynie.pbc
-
-# &
-
-print('test: boolean logic 0 AND 0')
-x = 0 & 0
-if x == 0: print('success: boolean logic 0 AND 0')
-else:
-    print('failure: boolean logic 0 AND 0 [')
-    print('03-op-logic.py:6:FAIL test expected 0, not', end=' ')
-    print(x)
-    print(']')
-
-print('test: boolean logic 0 AND 1')
-x = 0 & 1
-if x == 0: print('success: boolean logic 0 AND 1')
-else:
-    print('failure: boolean logic 0 AND 1 [')
-    print('03-op-logic.py:15:FAIL test expected 0, not', end=' ')
-    print(x)
-    print(']')
-
-print('test: boolean logic 1 AND 0')
-x = 1 & 0
-if x == 0: print('success: boolean logic 1 AND 0')
-else:
-    print('failure: boolean logic 1 AND 0 [')
-    print('03-op-logic.py:24:FAIL test expected 0, not', end=' ')
-    print(x)
-    print(']')
-
-print('test: boolean logic 1 AND 1')
-x = 1 & 1
-if x == 1: print('success: boolean logic 1 AND 1')
-else:
-    print('failure: boolean logic 1 AND 1 [')
-    print('03-op-logic.py:33:FAIL test expected 1, not', end=' ')
-    print(x)
-    print(']')
-
-# |
-
-print('test: boolean logic 0 OR 0')
-x = 0 | 0
-if x == 0: print('success: boolean logic 0 OR 0')
-else:
-    print('failure: boolean logic 0 OR 0 [')
-    print('03-op-logic.py:6:FAIL test expected 0, not', end=' ')
-    print(x)
-    print(']')