From 43a8442f14265be1b5c445544c8eaf7e26a449ef Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Tue, 11 Apr 2000 05:09:38 +0000 Subject: [PATCH] defineFunction, added assert --- js/js2/js2.cpp | 8 +++----- js2/tests/cpp/js2_shell.cpp | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/js/js2/js2.cpp b/js/js2/js2.cpp index 144c5b8395dd..8f68d2079cf4 100644 --- a/js/js2/js2.cpp +++ b/js/js2/js2.cpp @@ -388,8 +388,7 @@ static float64 testFunctionCall(World &world, float64 n) // preset the global property "sum" to contain the above function - JSValue v(funCode); - defineGlobalProperty(widenCString("sum"), JSValue(v)); + defineFunction(sum, funCode); JSValue result = interpret(script.complete(), JSValues()); std::cout << "sum(" << n << ") = " << result.f64 << std::endl; @@ -439,8 +438,7 @@ static float64 testFactorial(World &world, float64 n) // preset the global property "fact" to contain the above function StringAtom& fact = world.identifiers[widenCString("fact")]; - JSValue v(icm); - defineGlobalProperty(fact, v); + defineFunction(fact, icm); // now a script : // return fact(n); @@ -534,7 +532,7 @@ int main(int argc, char **argv) assert(testFactorial(world, 5) == 120); assert(testObjects(world, 5) == 5); // testICG(world); - testFunctionCall(world, 5); + assert(testFunctionCall(world, 5) == 5); #endif readEvalPrint(stdin, world); return 0; diff --git a/js2/tests/cpp/js2_shell.cpp b/js2/tests/cpp/js2_shell.cpp index 144c5b8395dd..8f68d2079cf4 100644 --- a/js2/tests/cpp/js2_shell.cpp +++ b/js2/tests/cpp/js2_shell.cpp @@ -388,8 +388,7 @@ static float64 testFunctionCall(World &world, float64 n) // preset the global property "sum" to contain the above function - JSValue v(funCode); - defineGlobalProperty(widenCString("sum"), JSValue(v)); + defineFunction(sum, funCode); JSValue result = interpret(script.complete(), JSValues()); std::cout << "sum(" << n << ") = " << result.f64 << std::endl; @@ -439,8 +438,7 @@ static float64 testFactorial(World &world, float64 n) // preset the global property "fact" to contain the above function StringAtom& fact = world.identifiers[widenCString("fact")]; - JSValue v(icm); - defineGlobalProperty(fact, v); + defineFunction(fact, icm); // now a script : // return fact(n); @@ -534,7 +532,7 @@ int main(int argc, char **argv) assert(testFactorial(world, 5) == 120); assert(testObjects(world, 5) == 5); // testICG(world); - testFunctionCall(world, 5); + assert(testFunctionCall(world, 5) == 5); #endif readEvalPrint(stdin, world); return 0;