Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9231: line.patch

File line.patch, 0.6 kB (added by jeresig, 3 years ago)

Add Line Numbers to Failures

  • test/lib/unittest.js

    old new  
    277277  }, 
    278278  fail: function(message) { 
    279279    this.failures++; 
    280     this.messages.push("Failure: " + message); 
     280 
     281    var line = ""; 
     282    try { 
     283      throw new Error("stack"); 
     284    } catch(e){ 
     285      line = (/\.html:(\d+)/.exec(e.stack || '') || ['',''])[1]; 
     286    } 
     287 
     288    this.messages.push("Failure: " + message + (line ? " Line #" + line : "")); 
    281289  }, 
    282290  info: function(message) { 
    283291    this.messages.push("Info: " + message);