mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Move js-analyze tests to a separate package to simplify loading
This commit is contained in:
1
packages/js-analyze-tests/.gitignore
vendored
Normal file
1
packages/js-analyze-tests/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.build*
|
||||
12
packages/js-analyze-tests/package.js
Normal file
12
packages/js-analyze-tests/package.js
Normal file
@@ -0,0 +1,12 @@
|
||||
Package.describe({
|
||||
summary: "Tests for JavaScript code analysis for Meteor"
|
||||
});
|
||||
|
||||
// The tests are in a separate package so that it is possible to compile
|
||||
// 'js-analyze' as a unipackage and then load it via `unipackage.load` without
|
||||
// any dependencies.
|
||||
Package.on_test(function (api) {
|
||||
api.use('tinytest');
|
||||
api.use('js-analyze');
|
||||
api.add_files('js_analyze_tests.js', 'server');
|
||||
});
|
||||
@@ -1,40 +0,0 @@
|
||||
var esprima = Npm.require('esprima');
|
||||
var escope = Npm.require('escope');
|
||||
var estraverse = Npm.require('estraverse');
|
||||
|
||||
Tinytest.add("estools - parser", function (test) {
|
||||
var tree = esprima.parse('1+1');
|
||||
test.equal(tree, {
|
||||
"type": "Program",
|
||||
"body": [{
|
||||
"type": "ExpressionStatement",
|
||||
"expression": {
|
||||
"type": "BinaryExpression",
|
||||
"operator": "+",
|
||||
"left": {
|
||||
"type": "Literal",
|
||||
"value": 1,
|
||||
"raw": "1"
|
||||
},
|
||||
"right": {
|
||||
"type": "Literal",
|
||||
"value": 1,
|
||||
"raw": "1"}}}]
|
||||
});
|
||||
});
|
||||
|
||||
Tinytest.add("estools - scoper", function (test) {
|
||||
var tree = esprima.parse('var x = 1');
|
||||
var scoper = escope.analyze(tree);
|
||||
scoper.attach();
|
||||
|
||||
var getScope = function (node) {
|
||||
return node[escope.Scope.mangledName];
|
||||
};
|
||||
var Syntax = estraverse.Syntax;
|
||||
|
||||
var refs = getScope(tree).references;
|
||||
test.equal(refs.length, 1);
|
||||
test.equal(refs[0].flag, escope.Reference.WRITE);
|
||||
test.equal(refs[0].identifier, { type: Syntax.Identifier, name: "x" });
|
||||
});
|
||||
@@ -13,20 +13,13 @@ Npm.depends({
|
||||
escope: "0.0.14"
|
||||
});
|
||||
|
||||
// This package may not depend on ANY other Meteor packages. This is because it
|
||||
// is used by the linker; the linker is smart enough not to try to apply it to
|
||||
// itself, but it cannot depend on any other packages or else it would be
|
||||
// impossible to load at link time (or all transitive dependencies packages
|
||||
// would need to function without the analysis provided by this package).
|
||||
// This package may not depend on ANY other Meteor packages, even in the test
|
||||
// slice. (Tests for this package are in the js-analyze-tests package.) This is
|
||||
// because it is used by the linker; the linker is smart enough not to try to
|
||||
// apply it to itself, but it cannot depend on any other packages or else it
|
||||
// would be impossible to load at link time (or all transitive dependencies
|
||||
// packages would need to function without the analysis provided by this
|
||||
// package).
|
||||
Package.on_use(function (api, where) {
|
||||
api.add_files('js_analyze.js', 'server');
|
||||
});
|
||||
|
||||
// It's OK to have dependencies here, though, because unipackage.load doesn't
|
||||
// need to load dependencies of test slices.
|
||||
Package.on_test(function (api) {
|
||||
api.use('tinytest');
|
||||
api.use('js-analyze');
|
||||
api.add_files('esprima_tests.js', 'server');
|
||||
api.add_files('js_analyze_tests.js', 'server');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user