mirror of https://github.com/pyodide/pyodide.git
Convert integer-only doubles to PyLong (#512)
* Convert integer-only doubles to PyLong * Using PyLong_FromDouble directly, improved tests * This test should to it as well
This commit is contained in:
parent
74b4461bda
commit
16c512f272
|
@ -23,6 +23,11 @@ _js2python_get_ptr(int obj)
|
|||
int
|
||||
_js2python_number(double val)
|
||||
{
|
||||
double i;
|
||||
|
||||
if (modf(val, &i) == 0.0)
|
||||
return (int)PyLong_FromDouble(i);
|
||||
|
||||
return (int)PyFloat_FromDouble(val);
|
||||
}
|
||||
|
||||
|
|
|
@ -224,10 +224,10 @@ def test_js2python(selenium):
|
|||
'jsstring_ucs4 == "🐍"')
|
||||
assert selenium.run(
|
||||
'from js import jsnumber0\n'
|
||||
'jsnumber0 == 42')
|
||||
'jsnumber0 == 42 and isinstance(jsnumber0, int)')
|
||||
assert selenium.run(
|
||||
'from js import jsnumber1\n'
|
||||
'jsnumber1 == 42.5')
|
||||
'jsnumber1 == 42.5 and isinstance(jsnumber1, float)')
|
||||
assert selenium.run(
|
||||
'from js import jsundefined\n'
|
||||
'jsundefined is None')
|
||||
|
|
Loading…
Reference in New Issue