mustache/js/node_modules/mustache/test/scanner-test.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
require('./helper');
var Scanner = Mustache.Scanner;
describe('A new Mustache.Scanner', function () {
describe('for an empty string', function () {
it('is at the end', function () {
var scanner = new Scanner('');
assert(scanner.eos());
});
});
describe('for a non-empty string', function () {
var scanner;
beforeEach(function () {
scanner = new Scanner('a b c');
});
describe('scan', function () {
describe('when the RegExp matches the entire string', function () {
it('returns the entire string', function () {
var match = scanner.scan(/a b c/);
assert.equal(match, scanner.string);
assert(scanner.eos());
});
});
describe('when the RegExp matches at index 0', function () {
it('returns the portion of the string that matched', function () {
var match = scanner.scan(/a/);
assert.equal(match, 'a');
assert.equal(scanner.pos, 1);
});
});
describe('when the RegExp matches at some index other than 0', function () {
it('returns the empty string', function () {
var match = scanner.scan(/b/);
assert.equal(match, '');
assert.equal(scanner.pos, 0);
});
});
describe('when the RegExp does not match', function () {
it('returns the empty string', function () {
var match = scanner.scan(/z/);
assert.equal(match, '');
assert.equal(scanner.pos, 0);
});
});
}); // scan
describe('scanUntil', function () {
describe('when the RegExp matches at index 0', function () {
it('returns the empty string', function () {
var match = scanner.scanUntil(/a/);
assert.equal(match, '');
assert.equal(scanner.pos, 0);
});
});
后面还有 18 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
