From 5ec31c8f6541710ddf7d6365f4a0651be009f48d Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 19 Apr 2013 06:16:49 -0600 Subject: [PATCH] ffi/unsafe: add `_double' and `_float' tests --- collects/tests/racket/foreign-test.c | 4 ++++ collects/tests/racket/foreign-test.rktl | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/collects/tests/racket/foreign-test.c b/collects/tests/racket/foreign-test.c index 9a95e173d8..3e3191bb1d 100644 --- a/collects/tests/racket/foreign-test.c +++ b/collects/tests/racket/foreign-test.c @@ -12,6 +12,8 @@ X int add1_int_int (int x) { return x + 1; } X int add1_byte_int (byte x) { return x + 1; } X byte add1_int_byte (int x) { return x + 1; } X byte add1_byte_byte (byte x) { return x + 1; } +X float add1_float_float (float x) { return x + 1; } +X double add1_double_double (double x) { return x + 1; } X int decimal_int_int_int (int x, int y) { return 10*x + y; } X int decimal_byte_int_int (byte x, int y) { return 10*x + y; } X int decimal_int_byte_int (int x, byte y) { return 10*x + y; } @@ -36,6 +38,8 @@ X byte callback3_int_byte_byte (byte(*f)(int)) { return f(3); } X short callback3_int_short_short (short(*f)(int)) { return f(3); } X byte callback3_byte_byte_byte (byte(*f)(byte)) { return f(3); } X short callback3_short_short_short(short(*f)(short)) { return f(3); } +X float callback3_float_float_float(float(*f)(float)) { return f(3.0); } +X double callback3_double_double_double(double(*f)(double)) { return f(3.0); } X int g1; X int curry_ret_int_int (int x) { return g1 + x; } diff --git a/collects/tests/racket/foreign-test.rktl b/collects/tests/racket/foreign-test.rktl index e0345d8a5b..65d3ee8694 100644 --- a/collects/tests/racket/foreign-test.rktl +++ b/collects/tests/racket/foreign-test.rktl @@ -146,6 +146,10 @@ (t 2 'add1_byte_byte (_fun _byte -> _byte) 1) (t -1 'add1_int_int (_fun _int -> _int ) -2) (t -1 'add1_int_int (_fun _int -> _fixint ) -2) + (t 2.0 'add1_float_float (_fun _float -> _float) 1.0) + (t -1.0 'add1_float_float (_fun _float -> _float) -2.0) + (t 2.0 'add1_double_double (_fun _double -> _double) 1.0) + (t -1.0 'add1_double_double (_fun _double -> _double) -2.0) ;; --- (t 12 'decimal_int_int_int (_fun _int _int -> _int ) 1 2) (t 12 'decimal_byte_int_int (_fun _byte _int -> _int ) 1 2) @@ -173,6 +177,8 @@ (t 9 'callback3_int_short_short (_fun (_fun _int -> _short) -> _short) sqr) (t 9 'callback3_byte_byte_byte (_fun (_fun _byte -> _byte) -> _byte) sqr) (t 9 'callback3_short_short_short (_fun (_fun _short -> _short) -> _short) sqr) + (t 9.0 'callback3_float_float_float (_fun (_fun _float -> _float) -> _float) sqr) + (t 9.0 'callback3_double_double_double (_fun (_fun _double -> _double) -> _double) sqr) ;; --- (tc 3 'curry_int_int_int (_fun _int -> (_fun _int -> _int )) 1 2) (tc 3 'curry_byte_int_int (_fun _byte -> (_fun _int -> _int )) 1 2)