Skip to content

Commit

Permalink
Get the tests 100% green with common js module system
Browse files Browse the repository at this point in the history
  • Loading branch information
smtlaissezfaire committed Apr 4, 2010
1 parent aa29764 commit f3240e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion jslex.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

function TokenDef(pattern, callbackfn) {
this.match = function match(text) {
var trimmed = text.trimBegin();
var trimmed = text.trim();
var match = trimmed.match(pattern);
if (match && match.index == 0) {
var newText = trimmed.substr(match[0].length);
Expand Down Expand Up @@ -77,3 +77,8 @@ function jsLex(tokenDefs, text) {

return tokenStream;
}

if (typeof(exports) !== "undefined") {
exports.TokenDef = TokenDef;
exports.jsLex = jsLex;
}
6 changes: 5 additions & 1 deletion jslex_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/;
load("jslex.js");

var lexer = require("./jslex");

var TokenDef = lexer.TokenDef;
var jsLex = lexer.jsLex;

function testTokenMatch() {
var result = true;
Expand Down

0 comments on commit f3240e8

Please sign in to comment.