Permalink
Browse files

test coverage

  • Loading branch information...
leizongmin committed Mar 15, 2013
1 parent 28e0563 commit ae7b3d593e6749e99f80291e8e24411fbab6f20a
Showing with 26 additions and 16 deletions.
  1. +3 −0 bin/coverage.sh
  2. +22 −12 index.js
  3. +0 −3 test.cmd
  4. +1 −1 test/filters.js
View
@@ -0,0 +1,3 @@
+jscover lib lib-cov
+set TINYLIQUID_COV=true
+mocha -R html-cov test/ --coverage > coverage.html
View
@@ -4,15 +4,29 @@
* @author Lei Zongmin<leizongmin@gmail.com>
*/
-
-// TinyLiquid Version
-exports.version = require('./package.json').version;
+// testing coverage?
+var TINYLIQUID_COV = /true/.test(process.env.TINYLIQUID_COV);
+var libPath = function (name) {
+ return (TINYLIQUID_COV ? './lib-cov' : './lib') + '/' + name;
+};
+
+var domain = require('domain');
+var packageInfo = require('./package.json');
+var parser = require(libPath('parser'));
+var vm = require(libPath('vm'));
+var Context = require(libPath('context'));
+var filters = require(libPath('filters'));
+var utils = require(libPath('utils'));
+
+
+// TinyLiquid version
+exports.version = packageInfo.version;
// AST parser
-var parser = require('./lib/parser');
exports.parser = parser;
+
/**
* Parse template
*
@@ -25,10 +39,6 @@ exports.parse = function (tpl, options) {
};
-// VM
-var domain = require('domain');
-var vm = require('./lib/vm');
-
/**
* Run AST code
*
@@ -41,7 +51,7 @@ exports.run = function (astList, context, callback) {
if (arguments.length < 3) throw new Error('Not enough arguments.');
// if astList is not an AST array, then parse it firstly
- if (!Array.isArray(astList)) astList = parser(astList);
+ if (!Array.isArray(astList)) astList = exports.parse(astList);
// ensure that the callback function is called only once
var originCallback = callback;
@@ -85,7 +95,7 @@ exports.comiple = function (tpl, options) {
// Context
-var Context = exports.Context = require('./lib/context');
+exports.Context = Context;
/**
* Create a new context
@@ -99,8 +109,8 @@ exports.newContext = function (options) {
// Utils
-exports.utils = require('./lib/utils');
+exports.utils = utils;
// Default filters
-exports.filters = require('./lib/filters');
+exports.filters = filters;
View
@@ -1,3 +0,0 @@
-@echo off
-node dev/test
-mocha
View
@@ -3,7 +3,7 @@
*/
var assert = require('assert');
-var filters = require('../lib/filters');
+var filters = require('../').filters;
describe('filters', function () {

0 comments on commit ae7b3d5

Please sign in to comment.