Revision: 4151 http://vexi.svn.sourceforge.net/vexi/?rev=4151&view=rev Author: mkpg2 Date: 2011-05-22 16:14:04 +0000 (Sun, 22 May 2011)
Log Message: ----------- Convenience. For now convert decimal to number. (Later will most likely make decimal a first class number type). Modified Paths: -------------- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDecimal.jpp trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp trunk/org.vexi-library.js/src/test/java/test/js/exec/date/methods.js trunk/org.vexi-library.js/src/test/java/test/js/exec/date/sort.js trunk/org.vexi-library.js/src/test/java/test/js/exec/number/TestNumber.java trunk/org.vexi-library.js/src/test/java/test/js/exec/number/lib.js trunk/org.vexi-library.js/src/test/java/test/js/exec/shared.js Added Paths: ----------- trunk/org.vexi-library.js/src/test/java/test/js/exec/date/decimal_arg.js Removed Paths: ------------- trunk/org.vexi-library.js/src/test/java/test/js/exec/date/lib.js Modified: trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDecimal.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDecimal.jpp 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDecimal.jpp 2011-05-22 16:14:04 UTC (rev 4151) @@ -194,8 +194,8 @@ } // REMARK may implement JSNumber -// int toInt() { return decimal.intValue(); } -// long toLong(){ return decimal.longValue(); } -// double toDouble() { return decimal.doubleValue(); } + int toInt() { return decimal.intValue(); } + long toLong(){ return decimal.longValue(); } + double toDouble() { return decimal.doubleValue(); } } Modified: trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp 2011-05-22 16:14:04 UTC (rev 4151) @@ -96,7 +96,7 @@ throw new JSExn("This string is not a number: \""+o.coerceToString()+'"'); } } -// if(o instanceof JSDecimal) return ((JSDecimal)o).toLong(); + if(o instanceof JSDecimal) return ((JSDecimal)o).toLong(); if(o instanceof JSBoolean) return ((JSBoolean)o).toLong(); throw new JSExn("Can not coerce a " + o.getClass().getName() + " to a number"); } Added: trunk/org.vexi-library.js/src/test/java/test/js/exec/date/decimal_arg.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/date/decimal_arg.js (rev 0) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/date/decimal_arg.js 2011-05-22 16:14:04 UTC (rev 4151) @@ -0,0 +1,8 @@ +sys.import("shared"); + +const Date = sys.js.Date; +const Decimal = sys.js.Decimal; +// TODAY +var today = Date.today; +var today_ = today.addPeriod("month",Decimal.cast(6)).addPeriod("month",-6); +assertEquals(today, today_); Property changes on: trunk/org.vexi-library.js/src/test/java/test/js/exec/date/decimal_arg.js ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: trunk/org.vexi-library.js/src/test/java/test/js/exec/date/lib.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/date/lib.js 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/date/lib.js 2011-05-22 16:14:04 UTC (rev 4151) @@ -1,17 +0,0 @@ -export.assertUndefined = function(v){ - if(v==null) - return; - sys.log.info("Expected null, got " + v); - assert(false); -}; - -export.assertEquals = function(a,b){ - if(a==b) - return; - sys.log.info("Expected equals: " + a + " != " + b); - assert(false); -}; - -export.skip = function(msg){ - sys.log.info("SKIPPING : " + msg); -}; Modified: trunk/org.vexi-library.js/src/test/java/test/js/exec/date/methods.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/date/methods.js 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/date/methods.js 2011-05-22 16:14:04 UTC (rev 4151) @@ -1,7 +1,5 @@ -sys.import("lib"); +sys.import("shared"); -sys.import("lib"); - const Date = sys.js.Date; // TODAY Modified: trunk/org.vexi-library.js/src/test/java/test/js/exec/date/sort.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/date/sort.js 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/date/sort.js 2011-05-22 16:14:04 UTC (rev 4151) @@ -1,4 +1,4 @@ -sys.import("lib"); +sys.import("shared"); const Date = sys.js.Date; var array = [ @@ -10,4 +10,4 @@ array.sort(); -assertEquals("2010-1-4,2010-12-1,2011-1,2011-1-3", array.join(",")); +assertEquals("2010-01-04,2010-12-01,2011-01,2011-01-03", array.join(",")); Modified: trunk/org.vexi-library.js/src/test/java/test/js/exec/number/TestNumber.java =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/number/TestNumber.java 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/number/TestNumber.java 2011-05-22 16:14:04 UTC (rev 4151) @@ -1,6 +1,7 @@ package test.js.exec.number; import junit.framework.Test; +import test.js.exec.JSTestCase; import test.js.exec.JSTestSuite; /** @@ -11,4 +12,15 @@ public static Test suite() { return JSTestSuite.suite(TestNumber.class); } + + public static void main(String[] args) throws Throwable { + try{ + JSTestSuite jts = new JSTestSuite(TestNumber.class); + JSTestCase t = jts.createTestCase(jts.getResourceDirs(), "testDataNumber2.js"); + //t.printByteCode(); + t.runBare(); + }catch(Throwable t){ + t.printStackTrace(); + } + } } Modified: trunk/org.vexi-library.js/src/test/java/test/js/exec/number/lib.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/number/lib.js 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/number/lib.js 2011-05-22 16:14:04 UTC (rev 4151) @@ -17,7 +17,7 @@ export.assertExactly = function (a,b) { // to 15 digits accuracy if (!(arguments.length == 2 && a != null && b != null)) { - fail("assertExactly should have 2 arguments"); + export.fail("assertExactly should have 2 arguments"); } assert((a>b*0.999999999999999 ) == (b*1.000000000000001>a)); assert(((a >= b*(1-1e-15)) && ( b*(1+1e-15)>=a)) Modified: trunk/org.vexi-library.js/src/test/java/test/js/exec/shared.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/shared.js 2011-05-22 15:54:08 UTC (rev 4150) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/shared.js 2011-05-22 16:14:04 UTC (rev 4151) @@ -66,3 +66,7 @@ throw "Expected exception"; }; + +export.skip = function(msg){ + sys.log.info("SKIPPING : " + msg); +}; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ What Every C/C++ and Fortran developer Should Know! Read this article and learn how Intel has extended the reach of its next-generation tools to help Windows* and Linux* C/C++ and Fortran developers boost performance applications - including clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn