aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-02 13:20:20 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-02 13:20:20 -0700
commitd061071c37db687389e2f8aad64741d1ce9a2ad0 (patch)
tree9d075504e06bb0bbc539b96aa4b2b39251408604 /tests/runner.py
parent1823aaf13bfbbc3cbbe6c8dc9ff153361f0bcf4a (diff)
only include i64 precise code if it will actually be used
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 62d09ee9..42cb211f 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -860,8 +860,37 @@ m_divisor is 1091269979
'''
self.do_run(src, open(path_from_root('tests', 'i64_precise.txt')).read())
+ # Verify that without precision, we do not include the precision code
+ Settings.PRECISE_I64_MATH = 0
+ self.do_run(src, 'unsigned')
+ code = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read()
+ assert 'goog.math.Long' not in code and 'jsbn' not in code, 'i64 precise math should not have been included if not asked for'
+
+ # Verify that even if we ask for precision, if it is not needed it is not included
+ Settings.PRECISE_I64_MATH = 1
+ src = '''
+ #include <inttypes.h>
+ #include <stdio.h>
+
+ int main(int argc, char **argv) {
+ uint64_t x = 2125299906845564, y = 1225891506842664;
+ if (argc == 12) {
+ x = x >> 1;
+ y = y >> 1;
+ }
+ x = x & 12ULL;
+ y = y | 12ULL;
+ x = x ^ y;
+ x <<= 2;
+ y >>= 3;
+ printf("*%llu, %llu*\\n", x, y);
+ }
+ '''
+ self.do_run(src, '*4903566027370624, 153236438355333*')
+ code = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read()
+ assert 'goog.math.Long' not in code and 'jsbn' not in code, 'i64 precise math should not have been included if not actually used'
+
print 'TODO: make precise the default, and imprecise in -O3. Remove precise setting in this test and cube2hash'
- print 'TODO: only include this code when needed'
#1/0.
def test_cube2hash(self):