Commits

Anonymous committed e261da5

add ability for assert function to take a single boolean argument

Comments (0)

Files changed (1)

                         return stack;
                 },
                 assert:function(a,b,strict){
+
+                        if(typeof b === "undefined")
+                        {
+                                if(a) return;
+
+                                var stack = fox.test.getStack();
+                                if(!stack) throw new Error(a);
+                                throw new Error(JSON.stringify({
+                                        function: stack[1].caller,
+                                        line: stack[1].line
+                                }));
+                        }
+
                         if(typeof strict === "undefined") strict = false;
 
                         if((strict && a !== b) || (!strict && a != b))
                         {
                                 var r = strict ? " !== " : " != ";
-                                var stack = getStack();
+                                var stack = fox.test.getStack();
+                                if(!stack) throw new Error(a + r + b);
 
                                 if(typeof a !== "string")
                                         a = JSON.stringify(a);
                                         function: stack[1].caller,
                                         line: stack[1].line,
                                         assertion:a + r + b
-                                        }));
+                                }));
                         }
                 },
                 run:function(suite, verbose){