# Test jsage language modifications12# ^ is xor in python by default3assrt.equal(2^3, 1)4assrt.equal(2**3, 8)5# note the precedence, despite how I wrote this!6assrt.equal(2^3 + 1, 2^4)78from __python__ import exponent9# now ^ is exponent and ^^ is xor10assrt.equal(2^3, 8)11assrt.equal(2^^3, 1)12assrt.equal(2**3, 8)1314# ^ really **is** exponentiation, not xor, since the tokenizer does it.15# This means the precedence is correct (i.e., very high).16assrt.equal(2^3 + 1, 9)1718# note that eval is not changed. Maybe this is bad?19assrt.equal(eval('2^3'), 1)202122from __python__ import no_exponent23# now ^ is back (and ^^ would be a syntax error - can't test this)24assrt.equal(2^3, 1)2526# Ellipses range parsing27# Enable it:28from __python__ import ellipses2930# With numerical literals31assrt.equal(str([1..5]), 'range(1, 6)')3233# With expressions34a = 2; b = 735assrt.equal(str([a+a..b+2]), 'range(4, 10)')3637# With a function call38def f(n):39return n+140assrt.equal(str([f(10)..f(1000)]), 'range(11, 1002)')4142# With a floating point literal43assrt.equal(str([1.5..5]), 'range(1.5, 6)')4445# Numerical literals46from __python__ import numbers47# will parse all numbers as one less!48def Number(s):49return parseFloat(s) - parseFloat('1.0')50assrt.equal(2.5, parseFloat('1.5'))515253