Restore and fix infinity testcase for Javascript
This commit is contained in:
parent
1010fbaa8f
commit
bebd97e7f4
3 changed files with 6 additions and 6 deletions
|
|
@ -587,6 +587,7 @@ C_TEST_CASES += \
|
||||||
global_functions \
|
global_functions \
|
||||||
immutable_values \
|
immutable_values \
|
||||||
inctest \
|
inctest \
|
||||||
|
infinity \
|
||||||
integers \
|
integers \
|
||||||
keyword_rename \
|
keyword_rename \
|
||||||
lextype \
|
lextype \
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
%module infinity
|
%module infinity
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
/* C99 defines INFINITY
|
/* C99 defines INFINITY
|
||||||
Because INFINITY may be defined by compiler built-ins, we can't use #define.
|
Because INFINITY may be defined by compiler built-ins, we can't use #define.
|
||||||
Instead, expose the variable MYINFINITY and then use %rename to make it INFINITY in the scripting language.
|
Instead, expose the variable MYINFINITY and then use %rename to make it INFINITY in the scripting language.
|
||||||
*/
|
*/
|
||||||
%rename(INFINITY) MYINFINITY;
|
%rename(INFINITY) MYINFINITY;
|
||||||
|
|
||||||
|
%{
|
||||||
%inline %{
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/* C99 math.h defines INFINITY. If not available, this is the fallback. */
|
/* C99 math.h defines INFINITY. If not available, this is the fallback. */
|
||||||
|
|
@ -26,7 +23,7 @@
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define INFINITY (__builtin_inf())
|
#define INFINITY (__builtin_inf())
|
||||||
#elif defined(__clang__)
|
#elif defined(__clang__)
|
||||||
#if __has_builtin(__builtin_inf)
|
#if __has_builtin(__builtin_inf)
|
||||||
#define INFINITY (__builtin_inf())
|
#define INFINITY (__builtin_inf())
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -36,7 +33,9 @@
|
||||||
#define INFINITY (1e1000)
|
#define INFINITY (1e1000)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
/* This will allow us to bind the real INFINITY value through SWIG via MYINFINITY. Use %rename to fix the name. */
|
/* This will allow us to bind the real INFINITY value through SWIG via MYINFINITY. Use %rename to fix the name. */
|
||||||
const double MYINFINITY = INFINITY;
|
const double MYINFINITY = INFINITY;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
var infinity = require("./infinity");
|
var infinity = require("./infinity");
|
||||||
|
|
||||||
var my_infinity = infinity.INFINTY;
|
var my_infinity = infinity.INFINITY;
|
||||||
var ret_val = infinity.use_infinity(my_infinity);
|
var ret_val = infinity.use_infinity(my_infinity);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue