Permalink
Browse files

Get the tests 100% green with common js module system

  • Loading branch information...
smtlaissezfaire committed Apr 4, 2010
1 parent aa29764 commit f3240e8be6437eaf55102dc16bcf2f5f7f45e620
Showing with 11 additions and 2 deletions.
  1. +6 −1 jslex.js
  2. +5 −1 jslex_test.js
View
@@ -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);
@@ -77,3 +77,8 @@ function jsLex(tokenDefs, text) {
return tokenStream;
}
+
+if (typeof(exports) !== "undefined") {
+ exports.TokenDef = TokenDef;
+ exports.jsLex = jsLex;
+}
View
@@ -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;

0 comments on commit f3240e8

Please sign in to comment.