Revision: 3546
          http://vexi.svn.sourceforge.net/vexi/?rev=3546&view=rev
Author:   clrg
Date:     2009-07-10 16:12:59 +0000 (Fri, 10 Jul 2009)

Log Message:
-----------
Throw exceptions on illegal box dimension puts + test

Modified Paths:
--------------
    trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp

Added Paths:
-----------
    trunk/core/org.vexi.core/src_junit/test/core/box/layout/exceptions.t

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2009-07-10 15:48:51 UTC 
(rev 3545)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2009-07-10 16:12:59 UTC 
(rev 3546)
@@ -902,7 +902,8 @@
     /** set minwidth and fire traps if necessary - returns false iff 
setMaxwidth is called */
     private final boolean setMinWidth(int minwidth, boolean firetraps) throws 
JSExn {
         if (this.minwidth == minwidth) return true;
-        if (minwidth<0) throw new JSExn("Attempt to set maxwidth to a value 
lower than '"+0+"'");
+        if (minwidth<0 || minwidth>MAX_DIMENSION)
+            throw new JSExn("Attempt to set minwidth to a value outside the 
range 0-"+MAX_DIMENSION);
         if (firetraps && test(MINWIDTH_TRAP)) {
             Trap t = wtrap(SC_minwidth);
             // FIXME: investigate this
@@ -930,7 +931,8 @@
     /** set maxwidth and fire traps if necessary - returns false iff 
setMinwidth is called */
     private final boolean setMaxWidth(int maxwidth, boolean firetraps) throws 
JSExn {
         if (this.maxwidth == maxwidth) return true;
-        if (maxwidth>MAX_DIMENSION) throw new JSExn("Attempt to set maxwidth 
to a value higher than '"+MAX_DIMENSION+"'");
+        if (maxwidth<0 || maxwidth>MAX_DIMENSION)
+            throw new JSExn("Attempt to set maxwidth to a value outside the 
range 0-"+MAX_DIMENSION);
         if (firetraps && test(MAXWIDTH_TRAP)) {
             Trap t = wtrap(SC_maxwidth);
             // FIXME: investigate this

Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/exceptions.t
===================================================================
--- trunk/core/org.vexi.core/src_junit/test/core/box/layout/exceptions.t        
                        (rev 0)
+++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/exceptions.t        
2009-07-10 16:12:59 UTC (rev 3546)
@@ -0,0 +1,58 @@
+<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib">
+
+    var success;
+    var testForException = function(prop, value) {
+        success = false;
+        try {
+            var b = vexi.box;
+            b[prop] = value;
+            success = true;
+        } catch(e) {
+            return;
+        }
+    }
+    
+    testForException("minwidth", -1);
+    assert(success==false);
+    testForException("minwidth", 1);
+    assert(success==true);
+    testForException("minwidth", vexi.ui.maxdim+1);
+    assert(success==false);
+    
+    testForException("maxwidth", -1);
+    assert(success==false);
+    testForException("maxwidth", 1);
+    assert(success==true);
+    testForException("maxwidth", vexi.ui.maxdim+1);
+    assert(success==false);
+    
+    testForException("width", -1);
+    assert(success==false);
+    testForException("width", 1);
+    assert(success==true);
+    testForException("width", vexi.ui.maxdim+1);
+    assert(success==false);
+    
+    testForException("minheight", -1);
+    assert(success==false);
+    testForException("minheight", 1);
+    assert(success==true);
+    testForException("minheight", vexi.ui.maxdim+1);
+    assert(success==false);
+    
+    testForException("maxheight", -1);
+    assert(success==false);
+    testForException("maxheight", 1);
+    assert(success==true);
+    testForException("maxheight", vexi.ui.maxdim+1);
+    assert(success==false);
+    
+    testForException("height", -1);
+    assert(success==false);
+    testForException("height", 1);
+    assert(success==true);
+    testForException("height", vexi.ui.maxdim+1);
+    assert(success==false);
+    
+    <ui:box/>
+</vexi>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to