aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-08-23 18:53:05 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-08-23 18:53:05 -0700
commit2d927106834107f492ade2be6b183375be84555e (patch)
treee6ebce2c8a393d3675cc229cfb2a8ac76846d808 /tests
parentaf67804695835d1ce1e084614a886366768b2015 (diff)
parentcfcf669f7d0239e052ba2387eee94a64912e9f09 (diff)
Merge pull request #68 from max99x/master
Python- and Lua-related fixes + redundancy eliminator script
Diffstat (limited to 'tests')
-rw-r--r--tests/langinfo/output.txt56
-rw-r--r--tests/langinfo/test.c64
-rw-r--r--tests/runner.py68
3 files changed, 187 insertions, 1 deletions
diff --git a/tests/langinfo/output.txt b/tests/langinfo/output.txt
new file mode 100644
index 00000000..2464cf61
--- /dev/null
+++ b/tests/langinfo/output.txt
@@ -0,0 +1,56 @@
+ CODESET: "ANSI_X3.4-1968"
+ D_T_FMT: "%a %b %e %H:%M:%S %Y"
+ D_FMT: "%m/%d/%y"
+ T_FMT: "%H:%M:%S"
+ T_FMT_AMPM: "%I:%M:%S %p"
+ AM_STR: "AM"
+ PM_STR: "PM"
+ DAY_1: "Sunday"
+ DAY_2: "Monday"
+ DAY_3: "Tuesday"
+ DAY_4: "Wednesday"
+ DAY_5: "Thursday"
+ DAY_6: "Friday"
+ DAY_7: "Saturday"
+ ABDAY_1: "Sun"
+ ABDAY_2: "Mon"
+ ABDAY_3: "Tue"
+ ABDAY_4: "Wed"
+ ABDAY_5: "Thu"
+ ABDAY_6: "Fri"
+ ABDAY_7: "Sat"
+ MON_1: "January"
+ MON_2: "February"
+ MON_3: "March"
+ MON_4: "April"
+ MON_5: "May"
+ MON_6: "June"
+ MON_7: "July"
+ MON_8: "August"
+ MON_9: "September"
+ MON_10: "October"
+ MON_11: "November"
+ MON_12: "December"
+ ABMON_1: "Jan"
+ ABMON_2: "Feb"
+ ABMON_3: "Mar"
+ ABMON_4: "Apr"
+ ABMON_5: "May"
+ ABMON_6: "Jun"
+ ABMON_7: "Jul"
+ ABMON_8: "Aug"
+ ABMON_9: "Sep"
+ ABMON_10: "Oct"
+ ABMON_11: "Nov"
+ ABMON_12: "Dec"
+ ERA: ""
+ ERA_D_FMT: ""
+ ERA_D_T_FMT: ""
+ ERA_T_FMT: ""
+ ALT_DIGITS: ""
+ RADIXCHAR: "."
+ THOUSEP: ""
+ YESEXPR: "^[yY]"
+ NOEXPR: "^[nN]"
+ CRNCYSTR: "-"
+ (bad value): ""
diff --git a/tests/langinfo/test.c b/tests/langinfo/test.c
new file mode 100644
index 00000000..3b506835
--- /dev/null
+++ b/tests/langinfo/test.c
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <langinfo.h>
+
+int main() {
+ printf("%16s: \"%s\"\n", "CODESET", nl_langinfo(CODESET));
+ printf("%16s: \"%s\"\n", "D_T_FMT", nl_langinfo(D_T_FMT));
+ printf("%16s: \"%s\"\n", "D_FMT", nl_langinfo(D_FMT));
+ printf("%16s: \"%s\"\n", "T_FMT", nl_langinfo(T_FMT));
+ printf("%16s: \"%s\"\n", "T_FMT_AMPM", nl_langinfo(T_FMT_AMPM));
+ printf("%16s: \"%s\"\n", "AM_STR", nl_langinfo(AM_STR));
+ printf("%16s: \"%s\"\n", "PM_STR", nl_langinfo(PM_STR));
+ printf("%16s: \"%s\"\n", "DAY_1", nl_langinfo(DAY_1));
+ printf("%16s: \"%s\"\n", "DAY_2", nl_langinfo(DAY_2));
+ printf("%16s: \"%s\"\n", "DAY_3", nl_langinfo(DAY_3));
+ printf("%16s: \"%s\"\n", "DAY_4", nl_langinfo(DAY_4));
+ printf("%16s: \"%s\"\n", "DAY_5", nl_langinfo(DAY_5));
+ printf("%16s: \"%s\"\n", "DAY_6", nl_langinfo(DAY_6));
+ printf("%16s: \"%s\"\n", "DAY_7", nl_langinfo(DAY_7));
+ printf("%16s: \"%s\"\n", "ABDAY_1", nl_langinfo(ABDAY_1));
+ printf("%16s: \"%s\"\n", "ABDAY_2", nl_langinfo(ABDAY_2));
+ printf("%16s: \"%s\"\n", "ABDAY_3", nl_langinfo(ABDAY_3));
+ printf("%16s: \"%s\"\n", "ABDAY_4", nl_langinfo(ABDAY_4));
+ printf("%16s: \"%s\"\n", "ABDAY_5", nl_langinfo(ABDAY_5));
+ printf("%16s: \"%s\"\n", "ABDAY_6", nl_langinfo(ABDAY_6));
+ printf("%16s: \"%s\"\n", "ABDAY_7", nl_langinfo(ABDAY_7));
+ printf("%16s: \"%s\"\n", "MON_1", nl_langinfo(MON_1));
+ printf("%16s: \"%s\"\n", "MON_2", nl_langinfo(MON_2));
+ printf("%16s: \"%s\"\n", "MON_3", nl_langinfo(MON_3));
+ printf("%16s: \"%s\"\n", "MON_4", nl_langinfo(MON_4));
+ printf("%16s: \"%s\"\n", "MON_5", nl_langinfo(MON_5));
+ printf("%16s: \"%s\"\n", "MON_6", nl_langinfo(MON_6));
+ printf("%16s: \"%s\"\n", "MON_7", nl_langinfo(MON_7));
+ printf("%16s: \"%s\"\n", "MON_8", nl_langinfo(MON_8));
+ printf("%16s: \"%s\"\n", "MON_9", nl_langinfo(MON_9));
+ printf("%16s: \"%s\"\n", "MON_10", nl_langinfo(MON_10));
+ printf("%16s: \"%s\"\n", "MON_11", nl_langinfo(MON_11));
+ printf("%16s: \"%s\"\n", "MON_12", nl_langinfo(MON_12));
+ printf("%16s: \"%s\"\n", "ABMON_1", nl_langinfo(ABMON_1));
+ printf("%16s: \"%s\"\n", "ABMON_2", nl_langinfo(ABMON_2));
+ printf("%16s: \"%s\"\n", "ABMON_3", nl_langinfo(ABMON_3));
+ printf("%16s: \"%s\"\n", "ABMON_4", nl_langinfo(ABMON_4));
+ printf("%16s: \"%s\"\n", "ABMON_5", nl_langinfo(ABMON_5));
+ printf("%16s: \"%s\"\n", "ABMON_6", nl_langinfo(ABMON_6));
+ printf("%16s: \"%s\"\n", "ABMON_7", nl_langinfo(ABMON_7));
+ printf("%16s: \"%s\"\n", "ABMON_8", nl_langinfo(ABMON_8));
+ printf("%16s: \"%s\"\n", "ABMON_9", nl_langinfo(ABMON_9));
+ printf("%16s: \"%s\"\n", "ABMON_10", nl_langinfo(ABMON_10));
+ printf("%16s: \"%s\"\n", "ABMON_11", nl_langinfo(ABMON_11));
+ printf("%16s: \"%s\"\n", "ABMON_12", nl_langinfo(ABMON_12));
+ printf("%16s: \"%s\"\n", "ERA", nl_langinfo(ERA));
+ printf("%16s: \"%s\"\n", "ERA_D_FMT", nl_langinfo(ERA_D_FMT));
+ printf("%16s: \"%s\"\n", "ERA_D_T_FMT", nl_langinfo(ERA_D_T_FMT));
+ printf("%16s: \"%s\"\n", "ERA_T_FMT", nl_langinfo(ERA_T_FMT));
+ printf("%16s: \"%s\"\n", "ALT_DIGITS", nl_langinfo(ALT_DIGITS));
+ printf("%16s: \"%s\"\n", "RADIXCHAR", nl_langinfo(RADIXCHAR));
+ printf("%16s: \"%s\"\n", "THOUSEP", nl_langinfo(THOUSEP));
+ printf("%16s: \"%s\"\n", "YESEXPR", nl_langinfo(YESEXPR));
+ printf("%16s: \"%s\"\n", "NOEXPR", nl_langinfo(NOEXPR));
+ printf("%16s: \"%s\"\n", "CRNCYSTR", nl_langinfo(CRNCYSTR));
+
+ printf("%16s: \"%s\"\n", "(bad value)", nl_langinfo(123));
+
+ return 0;
+}
diff --git a/tests/runner.py b/tests/runner.py
index c6cc47b9..17403146 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1623,10 +1623,20 @@ if 'benchmark' not in sys.argv:
printf("*%.1f*\\n", strtod("66", NULL)); // checks dependency system, as our strtod needs _isspace etc.
+ printf("*%ld*\\n", strtol("10", NULL, 0));
+ printf("*%ld*\\n", strtol("0", NULL, 0));
+ printf("*%ld*\\n", strtol("-10", NULL, 0));
+ printf("*%ld*\\n", strtol("12", NULL, 16));
+
+ printf("*%lu*\\n", strtoul("10", NULL, 0));
+ printf("*%lu*\\n", strtoul("0", NULL, 0));
+ printf("*%lu*\\n", strtoul("-10", NULL, 0));
+
return 0;
}
'''
- self.do_test(src, '*1,2,3,5,5,6*\n*stdin==0:0*\n*%*\n*5*\n*66.0*\n*cleaned*')
+
+ self.do_test(src, '*1,2,3,5,5,6*\n*stdin==0:0*\n*%*\n*5*\n*66.0*\n*10*\n*0*\n*-10*\n*18*\n*10*\n*0*\n*4294967286*\n*cleaned*')
def test_time(self):
src = open(path_from_root('tests', 'time', 'src.c'), 'r').read()
@@ -2033,6 +2043,48 @@ if 'benchmark' not in sys.argv:
output_nicerizer=lambda x: x.replace('\n', '*'),
post_build=add_pre_run_and_checks)
+ def test_rand(self):
+ src = r'''
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ int main() {
+ printf("%d\n", rand());
+ printf("%d\n", rand());
+
+ srand(123);
+ printf("%d\n", rand());
+ printf("%d\n", rand());
+ srand(123);
+ printf("%d\n", rand());
+ printf("%d\n", rand());
+
+ unsigned state = 0;
+ int r;
+ r = rand_r(&state);
+ printf("%d, %u\n", r, state);
+ r = rand_r(&state);
+ printf("%d, %u\n", r, state);
+ state = 0;
+ r = rand_r(&state);
+ printf("%d, %u\n", r, state);
+
+ return 0;
+ }
+ '''
+ expected = '''
+ 1250496027
+ 1116302336
+ 440917656
+ 1476150784
+ 440917656
+ 1476150784
+ 12345, 12345
+ 1406932606, 3554416254
+ 12345, 12345
+ '''
+ self.do_test(src, re.sub(r'(^|\n)\s+', r'\1', expected))
+
def test_strtod(self):
src = r'''
#include <stdio.h>
@@ -2089,6 +2141,11 @@ if 'benchmark' not in sys.argv:
expected = open(path_from_root('tests', 'printf', 'output.txt'), 'r').read()
self.do_test(src, expected)
+ def test_langinfo(self):
+ src = open(path_from_root('tests', 'langinfo', 'test.c'), 'r').read()
+ expected = open(path_from_root('tests', 'langinfo', 'output.txt'), 'r').read()
+ self.do_test(src, expected)
+
def test_files(self):
global CORRECT_SIGNS; CORRECT_SIGNS = 1 # Just so our output is what we expect. Can flip them both.
def post(filename):
@@ -3729,6 +3786,15 @@ TT = %s
del T # T is just a shape for the specific subclasses, we don't test it itself
+ class OtherTests(RunnerCore):
+ def test_eliminator(self):
+ coffee = path_from_root('tools', 'eliminator', 'node_modules', 'coffee-script', 'bin', 'coffee')
+ eliminator = path_from_root('tools', 'eliminator', 'eliminator.coffee')
+ input = open(path_from_root('tools', 'eliminator', 'eliminator-test.js')).read()
+ expected = open(path_from_root('tools', 'eliminator', 'eliminator-test-output.js')).read()
+ output = Popen([coffee, eliminator], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate(input)[0]
+ self.assertEquals(output, expected)
+
else:
# Benchmarks