Revision: 4120
http://vexi.svn.sourceforge.net/vexi/?rev=4120&view=rev
Author: clrg
Date: 2011-05-10 13:39:37 +0000 (Tue, 10 May 2011)
Log Message:
-----------
FEATURE: more useful backtrace output by vunit
FEATURE: convert underscores to spaces for display
Modified Paths:
--------------
trunk/org.vexi-vexi.vunit/src_main/vexi/test/vunit.t
Modified: trunk/org.vexi-vexi.vunit/src_main/vexi/test/vunit.t
===================================================================
--- trunk/org.vexi-vexi.vunit/src_main/vexi/test/vunit.t 2011-05-10
12:46:02 UTC (rev 4119)
+++ trunk/org.vexi-vexi.vunit/src_main/vexi/test/vunit.t 2011-05-10
13:39:37 UTC (rev 4120)
@@ -61,6 +61,17 @@
for (v in obj) {
if (v.length>4 and v.substr(0,4)=="test") {
var name = v.substr(4,v.length-4);
+ // FEATURE replace underscores with spaces for nicer display
+ var split = name.split("_");
+ if (split.length>1) {
+ name = "";
+ for (var i=0; split.length>i; i++) {
+ if (split[i].length) {
+ if (name!="") name += " ";
+ name += split[i];
+ }
+ }
+ }
var tcase = newTestCase(name, obj[v]);
r.addTest(tcase);
}
@@ -297,13 +308,6 @@
vexi.js.stringify(actual));
}
- //aliases
- static.assertEq = assertEquals;
- static.assertGT = assertGreaterThan;
- static.assertGTE = assertGreaterThanEquals;
- static.assertLT = assertLessThan;
- static.assertLTE = assertLessThanEquals;
-
static.assertExceptionThrown = function(f) {
try {
f();
@@ -312,6 +316,51 @@
}
throw "expected exception";
};
+
+ // FEATURE remove vunit bits from the backtrace
+ var backtraceModifierReadTrap = function() {
+ // fetch the actual assertion function
+ var fun = cascade;
+ // return a wrapping function that executes the
+ // assertion function and modifies any exception
+ return function() {
+ try {
+ fun.apply(null, arguments);
+ } catch (e) {
+ var localtrace = [];
+ // step through hte backtrace and remove any
+ // entries that are generated by vunit code
+ for (var i,trace in e.backtrace)
+ if (trace.indexOf("vexi.test.vunit")!=0 and
trace.indexOf("org.vexi.vunit")!=0)
+ localtrace.push(trace);
+ // keep the full backtrace just in case
+ // TODO document this
+ e.fulltrace = e.backtrace;
+ // need to use a read trap as backtrace is created
+ // on-the-fly by the vexi code; writes are useless
+ e.backtrace ++= function() { return localtrace; }
+ throw e;
+ }
+ };
+ }
+ static.assertFalse ++= backtraceModifierReadTrap;
+ static.assertTrue ++= backtraceModifierReadTrap;
+ static.assertNotNull ++= backtraceModifierReadTrap;
+ static.assertEquals ++= backtraceModifierReadTrap;
+ static.assertApproxEquals ++= backtraceModifierReadTrap;
+ static.assertGreaterThan ++= backtraceModifierReadTrap;
+ static.assertGreaterThanEquals ++= backtraceModifierReadTrap;
+ static.assertLessrThan ++= backtraceModifierReadTrap;
+ static.assertLessrThanEquals ++= backtraceModifierReadTrap;
+ static.assertObjectEquals ++= backtraceModifierReadTrap;
+ static.assertExceptionThrown ++= backtraceModifierReadTrap;
+
+ //aliases
+ static.assertEq = assertEquals;
+ static.assertGT = assertGreaterThan;
+ static.assertGTE = assertGreaterThanEquals;
+ static.assertLT = assertLessThan;
+ static.assertLTE = assertLessThanEquals;
/////////
// ASYNC assertion stuff
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn