[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    tests/khtmltests/regression/tests/js
From:       Maks Orlovich <maksim () kde ! org>
Date:       2007-06-11 21:58:15
Message-ID: 1181599095.540768.26924.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 674163 by orlovich:

Merge in stuff from base.js into shell.js and make it not depend on tr 
so much, so we have only one file with all the helpers..


 D             base.js  
 M  +56 -4     shell.js  


--- trunk/tests/khtmltests/regression/tests/js/shell.js #674162:674163
@@ -9,15 +9,36 @@
 function testFailed(msg)
 {
   debug("FAIL. " + msg);
-  regtest.reportResult(false, msg);  
+  if (regtest)
+    regtest.reportResult(false, msg);  
 }
 
+function description(s)
+{
+    debug(s);
+}
+
+function evalError(arg, ex)
+{
+    //return "eval('" + arg + "') => " + ex.toString();
+    return ex.toString() + " [eval('" + arg + "')]";
+}
+
 function shouldBe(_a, _b)
 {
   if (typeof _a != "string" || typeof _b != "string")
     debug("WARN: shouldBe() expects string arguments");
-  var _av = eval(_a);
-  var _bv = eval(_b);
+  var _av, _bv;
+  try {
+    _av = eval(_a);
+  } catch (e) {
+    _av = evalError(_a, e);
+  }
+  try {
+    _bv = eval(_b);
+  } catch (e) {
+    _bv = evalError(_b, e);
+  }
 
   if (_av === _bv)
     testPassed(_a + " is " + _b);
@@ -31,9 +52,40 @@
 
 function shouldBeUndefined(_a)
 {
-  var _av = eval(_a);
+  var _av;
+  try {
+    _av = eval(_a);
+  } catch (e) {
+    _av = evalError(_a, e);
+  }
+
   if (typeof _av == "undefined")
     testPassed(_a + " is undefined.");
   else
     testFailed(_a + " should be undefined. Was " + _av);
 }
+
+function shouldThrow(_a, _e)
+{
+  var exception;
+  var _av;
+  try {
+     _av = eval(_a);
+  } catch (e) {
+     exception = e;
+  }
+
+  var _ev;
+  if (_e)
+      _ev =  eval(_e);
+
+  if (exception) {
+    if (typeof _e == "undefined" || exception == _ev)
+      testPassed(_a + " threw exception " + exception + ".");
+    else
+      testFailed(_a + " should throw exception " + _ev + ". Threw exception " + exception + ".");
+  } else if (typeof _av == "undefined")
+    testFailed(_a + " should throw exception " + _e + ". Was undefined.");
+  else
+    testFailed(_a + " should throw exception " + _e + ". Was " + _av + ".");
+}
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic