mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-06-05 22:09:23 +02:00
Transition to monorepo on a new Dev branch
This commit is contained in:
48
App/Source/node_modules/is-expression/test.js
generated
vendored
Normal file
48
App/Source/node_modules/is-expression/test.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var testit = require('testit');
|
||||
var isExpression = require('./');
|
||||
|
||||
function passes(src, options) {
|
||||
testit(JSON.stringify(src, options), function () {
|
||||
options = options || {};
|
||||
assert(isExpression(src, options));
|
||||
});
|
||||
}
|
||||
|
||||
testit('passes', function () {
|
||||
passes('myVar');
|
||||
passes('["an", "array", "\'s"].indexOf("index")');
|
||||
passes('\npublic');
|
||||
passes('abc // my comment', {lineComment: true});
|
||||
passes('() => a');
|
||||
passes('function (a = "default") {"use strict";}', {ecmaVersion: 6});
|
||||
});
|
||||
|
||||
function error(src, line, col, options) {
|
||||
testit(JSON.stringify(src), function () {
|
||||
options = options || {};
|
||||
assert(!isExpression(src, options));
|
||||
options.throw = true;
|
||||
assert.throws(function () {
|
||||
isExpression(src, options);
|
||||
}, function (err) {
|
||||
assert.equal(err.loc.line, line);
|
||||
assert.equal(err.loc.column, col);
|
||||
assert(err.message);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
testit('fails', function () {
|
||||
error('', 1, 0);
|
||||
error('var', 1, 0);
|
||||
error('weird error', 1, 6);
|
||||
error('asdf}', 1, 4);
|
||||
error('\npublic', 2, 0, {strict: true});
|
||||
error('abc // my comment', 1, 4);
|
||||
error('() => a', 1, 1, {ecmaVersion: 5});
|
||||
error('function (a = "default") {"use strict";}', 1, 26);
|
||||
});
|
Reference in New Issue
Block a user