Skip to content

Commit 310036a

Browse files
committed
Correcting tests and licenses.
1 parent 353a031 commit 310036a

File tree

4 files changed

+114
-86
lines changed

4 files changed

+114
-86
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_builtin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ def test_bin(self):
2424
# test of specializations
2525
self.assertEqual(bin(MyIndexable(False)), '0b0')
2626
self.assertEqual(bin(MyIndexable(True)), '0b1')
27-
self.assertEqual(bin(MyIndexable(-(2**65))), '-0b1' + '0' * 65)
27+
self.assertEqual(bin(MyIndexable(-(2**65))), '-0b1' + '0' * 65)

graalpython/com.oracle.graal.python.test/src/tests/test_math.py

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -955,52 +955,53 @@ def test_factorial(self):
955955
self.assertRaises(ValueError, math.factorial, -11.1)
956956

957957
def testGcd(self):
958-
gcd = math.gcd
959-
self.assertEqual(gcd(0, 0), 0)
960-
self.assertEqual(gcd(1, 0), 1)
961-
self.assertEqual(gcd(-1, 0), 1)
962-
self.assertEqual(gcd(0, 1), 1)
963-
self.assertEqual(gcd(0, -1), 1)
964-
self.assertEqual(gcd(7, 1), 1)
965-
self.assertEqual(gcd(7, -1), 1)
966-
self.assertEqual(gcd(-23, 15), 1)
967-
self.assertEqual(gcd(120, 84), 12)
968-
self.assertEqual(gcd(84, -120), 12)
969-
self.assertEqual(gcd(1216342683557601535506311712,
970-
436522681849110124616458784), 32)
971-
c = 652560
972-
x = 434610456570399902378880679233098819019853229470286994367836600566
973-
y = 1064502245825115327754847244914921553977
974-
a = x * c
975-
b = y * c
976-
self.assertEqual(gcd(a, b), c)
977-
self.assertEqual(gcd(b, a), c)
978-
self.assertEqual(gcd(-a, b), c)
979-
self.assertEqual(gcd(b, -a), c)
980-
self.assertEqual(gcd(a, -b), c)
981-
self.assertEqual(gcd(-b, a), c)
982-
self.assertEqual(gcd(-a, -b), c)
983-
self.assertEqual(gcd(-b, -a), c)
984-
c = 576559230871654959816130551884856912003141446781646602790216406874
985-
a = x * c
986-
b = y * c
987-
self.assertEqual(gcd(a, b), c)
988-
self.assertEqual(gcd(b, a), c)
989-
self.assertEqual(gcd(-a, b), c)
990-
self.assertEqual(gcd(b, -a), c)
991-
self.assertEqual(gcd(a, -b), c)
992-
self.assertEqual(gcd(-b, a), c)
993-
self.assertEqual(gcd(-a, -b), c)
994-
self.assertEqual(gcd(-b, -a), c)
995-
996-
self.assertRaises(TypeError, gcd, 120.0, 84)
997-
self.assertRaises(TypeError, gcd, 120, 84.0)
998-
self.assertEqual(gcd(MyIndexable(120), MyIndexable(84)), 12)
999-
1000-
# test of specializations
1001-
self.assertRaises(TypeError, gcd, 120, MyIndexable(6.0))
1002-
self.assertRaises(TypeError, gcd, 'ahoj', 1)
1003-
self.assertEqual(gcd(MyIndexable(True), MyIndexable(84)), 1)
958+
if (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
959+
gcd = math.gcd
960+
self.assertEqual(gcd(0, 0), 0)
961+
self.assertEqual(gcd(1, 0), 1)
962+
self.assertEqual(gcd(-1, 0), 1)
963+
self.assertEqual(gcd(0, 1), 1)
964+
self.assertEqual(gcd(0, -1), 1)
965+
self.assertEqual(gcd(7, 1), 1)
966+
self.assertEqual(gcd(7, -1), 1)
967+
self.assertEqual(gcd(-23, 15), 1)
968+
self.assertEqual(gcd(120, 84), 12)
969+
self.assertEqual(gcd(84, -120), 12)
970+
self.assertEqual(gcd(1216342683557601535506311712,
971+
436522681849110124616458784), 32)
972+
c = 652560
973+
x = 434610456570399902378880679233098819019853229470286994367836600566
974+
y = 1064502245825115327754847244914921553977
975+
a = x * c
976+
b = y * c
977+
self.assertEqual(gcd(a, b), c)
978+
self.assertEqual(gcd(b, a), c)
979+
self.assertEqual(gcd(-a, b), c)
980+
self.assertEqual(gcd(b, -a), c)
981+
self.assertEqual(gcd(a, -b), c)
982+
self.assertEqual(gcd(-b, a), c)
983+
self.assertEqual(gcd(-a, -b), c)
984+
self.assertEqual(gcd(-b, -a), c)
985+
c = 576559230871654959816130551884856912003141446781646602790216406874
986+
a = x * c
987+
b = y * c
988+
self.assertEqual(gcd(a, b), c)
989+
self.assertEqual(gcd(b, a), c)
990+
self.assertEqual(gcd(-a, b), c)
991+
self.assertEqual(gcd(b, -a), c)
992+
self.assertEqual(gcd(a, -b), c)
993+
self.assertEqual(gcd(-b, a), c)
994+
self.assertEqual(gcd(-a, -b), c)
995+
self.assertEqual(gcd(-b, -a), c)
996+
997+
self.assertRaises(TypeError, gcd, 120.0, 84)
998+
self.assertRaises(TypeError, gcd, 120, 84.0)
999+
self.assertEqual(gcd(MyIndexable(120), MyIndexable(84)), 12)
1000+
1001+
# test of specializations
1002+
self.assertRaises(TypeError, gcd, 120, MyIndexable(6.0))
1003+
self.assertRaises(TypeError, gcd, 'ahoj', 1)
1004+
self.assertEqual(gcd(MyIndexable(True), MyIndexable(84)), 1)
10041005

10051006
def test_floor(self):
10061007
class TestFloor:
@@ -1303,7 +1304,8 @@ def executeFnTest(self, values, fn, fnName):
13031304
self.assertTrue(math.isnan(result), "Test2 fail: {}({}) = {}, but was {}".format(fnName, value[0], expected, result))
13041305
else :
13051306
if result != expected:
1306-
self.assertTrue(math.isclose(result, expected, rel_tol=1e-12), "Test3 fail: {}({}) = {}, but was {}".format(fnName, value[0], expected, result))
1307+
if (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
1308+
self.assertTrue(math.isclose(result, expected, rel_tol=1e-14), "Test3 fail: {}({}) = {}, but was {}".format(fnName, value[0], expected, result))
13071309

13081310
def test_erf(self):
13091311
erfValues = [(0.0, 0.0), (-0.0, -0.0), (INF, 1.0), (NINF, -1.0), (NAN, NAN),

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/GetDoubleNode.java

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
3-
* Copyright (c) 2014, Regents of the University of California
2+
* Copyright (c) 2018, Oracle and/or its affiliates.
43
*
5-
* All rights reserved.
4+
* The Universal Permissive License (UPL), Version 1.0
65
*
7-
* Redistribution and use in source and binary forms, with or without modification, are
8-
* permitted provided that the following conditions are met:
6+
* Subject to the condition set forth below, permission is hereby granted to any
7+
* person obtaining a copy of this software, associated documentation and/or data
8+
* (collectively the "Software"), free of charge and under any and all copyright
9+
* rights in the Software, and any and all patent rights owned or freely
10+
* licensable by each licensor hereunder covering either (i) the unmodified
11+
* Software as contributed to or provided by such licensor, or (ii) the Larger
12+
* Works (as defined below), to deal in both
913
*
10-
* 1. Redistributions of source code must retain the above copyright notice, this list of
11-
* conditions and the following disclaimer.
12-
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
13-
* conditions and the following disclaimer in the documentation and/or other materials provided
14-
* with the distribution.
14+
* (a) the Software, and
15+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
* one is included with the Software (each a "Larger Work" to which the
17+
* Software is contributed by such licensors),
1518
*
16-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
17-
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19-
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21-
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22-
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
24-
* OF THE POSSIBILITY OF SUCH DAMAGE.
19+
* without restriction, including without limitation the rights to copy, create
20+
* derivative works of, display, perform, and distribute the Software and make,
21+
* use, sell, offer for sale, import, export, have made, and have sold the
22+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
* either these or other terms.
24+
*
25+
* This license is subject to the following condition:
26+
*
27+
* The above copyright notice and either this complete permission notice or at a
28+
* minimum a reference to the UPL must be included in all copies or substantial
29+
* portions of the Software.
30+
*
31+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37+
* SOFTWARE.
2538
*/
2639
package com.oracle.graal.python.nodes.util;
2740

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/GetIntNode.java

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
3-
* Copyright (c) 2014, Regents of the University of California
2+
* Copyright (c) 2018, Oracle and/or its affiliates.
43
*
5-
* All rights reserved.
4+
* The Universal Permissive License (UPL), Version 1.0
65
*
7-
* Redistribution and use in source and binary forms, with or without modification, are
8-
* permitted provided that the following conditions are met:
6+
* Subject to the condition set forth below, permission is hereby granted to any
7+
* person obtaining a copy of this software, associated documentation and/or data
8+
* (collectively the "Software"), free of charge and under any and all copyright
9+
* rights in the Software, and any and all patent rights owned or freely
10+
* licensable by each licensor hereunder covering either (i) the unmodified
11+
* Software as contributed to or provided by such licensor, or (ii) the Larger
12+
* Works (as defined below), to deal in both
913
*
10-
* 1. Redistributions of source code must retain the above copyright notice, this list of
11-
* conditions and the following disclaimer.
12-
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
13-
* conditions and the following disclaimer in the documentation and/or other materials provided
14-
* with the distribution.
14+
* (a) the Software, and
15+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
* one is included with the Software (each a "Larger Work" to which the
17+
* Software is contributed by such licensors),
1518
*
16-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
17-
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19-
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21-
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22-
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
24-
* OF THE POSSIBILITY OF SUCH DAMAGE.
19+
* without restriction, including without limitation the rights to copy, create
20+
* derivative works of, display, perform, and distribute the Software and make,
21+
* use, sell, offer for sale, import, export, have made, and have sold the
22+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
* either these or other terms.
24+
*
25+
* This license is subject to the following condition:
26+
*
27+
* The above copyright notice and either this complete permission notice or at a
28+
* minimum a reference to the UPL must be included in all copies or substantial
29+
* portions of the Software.
30+
*
31+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37+
* SOFTWARE.
2538
*/
2639
package com.oracle.graal.python.nodes.util;
2740

0 commit comments

Comments
 (0)