assert False, "Expected s.greetEveryoneExceptJack to throw JackError." except s.NimPyException as e: assert "Cannot greet Jack" in repr(e) assert "JackError" in repr(e) assert (s.somethingThatReturnsEmptyString() == "") assert (s.sumInts(4, 5) == 9) assert (abs(s.sumFloats(4.1, 5.2) - 9.3) < 0.0001) assert (abs(s.sumAssorted(1, 2, 3, 4, 5, 6, 7) - 28) < 0.0001) assert (s.sumIntsInArray([1, 2, 3, 4, 5, 6, 7]) == 28) assert (s.reverseArray([1, 2, 3]) == [3, 2, 1]) assert (s.reverseArray( (1, 2, 3)) == [3, 2, 1]) # Python tuples should be convertible to nim seqs assert (s.reverseVec3([1, 2, 3]) == [3, 2, 1]) assert (s.reverseVec3( (1, 2, 3)) == [3, 2, 1]) # Python tuples should be convertible to nim seqs assert (s.flipBool(False) is True) assert (s.flipBool(True) is False) assert (s.complexSqrt(complex(1, -1)) == cmath.sqrt(complex(1, -1))) assert (s.complexSeqSqrt([complex(1, -1), complex( 1, 1)]) == [cmath.sqrt(complex(1, -1)), cmath.sqrt(complex(1, 1))]) assert (s.sum_ints(3, 4) == 7) assert (s.getTable()["Hello"] == 0) assert (s.getTable()["SomeKey"] == 10) assert (s.getIntTable()[0] == 1.0) assert (s.getIntTable()[1] == 15.0) assert (s.getIntTable()[10] == 5.0)
import cmath, os import nimfrompy as s assert (s.greet("world") == "Hello, world!") assert (s.somethingThatReturnsEmptyString() == "") assert (s.sumInts(4, 5) == 9) assert (abs(s.sumFloats(4.1, 5.2) - 9.3) < 0.0001) assert (abs(s.sumAssorted(1, 2, 3, 4, 5, 6, 7) - 28) < 0.0001) assert (s.sumIntsInArray([1, 2, 3, 4, 5, 6, 7]) == 28) assert (s.reverseArray([1, 2, 3]) == [3, 2, 1]) assert (s.reverseVec3([1, 2, 3]) == [3, 2, 1]) assert (s.flipBool(False) == True) assert (s.flipBool(True) == False) assert (s.complexSqrt(complex(1, -1)) == cmath.sqrt(complex(1, -1))) assert (s.complexSeqSqrt([complex(1, -1), complex( 1, 1)]) == [cmath.sqrt(complex(1, -1)), cmath.sqrt(complex(1, 1))]) assert (s.sum_ints(3, 4) == 7) assert (s.getTable()["Hello"] == 0) assert (s.getTable()["SomeKey"] == 10) assert (s.getIntTable()[0] == 1.0) assert (s.getIntTable()[1] == 15.0) assert (s.getIntTable()[10] == 5.0) assert (s.TestType() != None) assert (s.getMyObj()["a"] == 5)