[seed] Distinguish between [null] and undefined in seed_Value_to_string. Format numbers with "%.15g"
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] Distinguish between [null] and undefined in seed_Value_to_string. Format numbers with "%.15g"
- Date: Mon, 4 May 2009 18:39:35 -0400 (EDT)
commit 9f89a9d5a063fef382e433d21089525544bac4e0
Author: Robert Carr <racarr svn gnome org>
Date: Mon May 4 18:39:24 2009 -0400
Distinguish between [null] and undefined in seed_Value_to_string. Format numbers with "%.15g"
---
libseed/seed-types.c | 9 ++++++---
tests/javascript/check-syntax.js | 2 +-
tests/javascript/everything.js | 3 ++-
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index ce8970c..f45fb8c 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -1766,14 +1766,17 @@ seed_value_to_string (JSContextRef ctx,
if (val == NULL)
return NULL;
-
- else if (JSValueIsNull (ctx, val) || JSValueIsUndefined (ctx, val))
+ else if (JSValueIsUndefined (ctx, val))
+ {
+ buf = g_strdup ("[undefined]");
+ }
+ else if (JSValueIsNull (ctx, val))
{
buf = g_strdup ("[null]");
}
else if (JSValueIsBoolean (ctx, val) || JSValueIsNumber (ctx, val))
{
- buf = g_strdup_printf ("%g", JSValueToNumber (ctx, val, NULL));
+ buf = g_strdup_printf ("%.15g", JSValueToNumber (ctx, val, NULL));
}
else
{
diff --git a/tests/javascript/check-syntax.js b/tests/javascript/check-syntax.js
index fcfb7a2..fcc9235 100755
--- a/tests/javascript/check-syntax.js
+++ b/tests/javascript/check-syntax.js
@@ -2,7 +2,7 @@
// Returns: 0
// STDIN:
// STDOUT:ONE\n\[null\]\nTWO\n\[null\]\nTHREE
-// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: SyntaxError\. Parse error in \[null\] at line 1
+// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: SyntaxError\. Parse error in \[undefined\] at line 1
Seed.print("ONE");
Seed.print(Seed.check_syntax("5+5;"));
diff --git a/tests/javascript/everything.js b/tests/javascript/everything.js
index 5024cfa..c4619b6 100755
--- a/tests/javascript/everything.js
+++ b/tests/javascript/everything.js
@@ -1,8 +1,9 @@
#!/usr/bin/env seed
// Returns: 0
// STDIN:
-// STDOUT:1\n-124\n129\n-1235\n1387\n-123435\n133487\n-1\.63234e\+07\n1\.38737e\+07\n-16325\n33737\n-16325\n33737\n12\n143\n-1853\.12\n-1\.34544e\+08\n8\n\["åäö","\/etc\/fstab"\]\n\["1","2","3"\]\n\["1","2","3"\]\n\["1","2","3"\]\n\["1","2","3"\]\n1,2,3\n5\n0\n123\n0\n1\n42\n1\n4\n15\n120\n120\.236\n42\n19
+// STDOUT:1\n-124\n129\n-1235\n1387\n-123435\n133487\n-16323375\n13873737\n-16325\n33737\n-16325\n33737\n12\n143\n-1853\.12329101562\n-134543853\.12334\n8\n\["åäö","\/etc\/fstab"\]\n\["1","2","3"\]\n\["1","2","3"\]\n\["1","2","3"\]\n\["1","2","3"\]\n1,2,3\n5\n0\n123\n0\n1\n42\n1\n4\n15\n120\n120\.2357\n42\n19
// STDERR:
+
Everything = imports.gi.Everything;
GObject = imports.gi.GObject;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]