Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
test with ecmaFeatures on by default, add test for #192
Browse files Browse the repository at this point in the history
Ref #192
  • Loading branch information
hzoo committed Oct 8, 2015
1 parent 521039c commit d2e3862
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions test/non-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,43 @@
"use strict";
var eslint = require("eslint");

function verifyAndAssertMessages(code, rules, expectedMessages) {
function verifyAndAssertMessages(code, rules, expectedMessages, features) {
var defaultEcmaFeatures = {
arrowFunctions: true,
binaryLiterals: true,
blockBindings: true,
classes: true,
defaultParams: true,
destructuring: true,
forOf: true,
generators: true,
modules: true,
objectLiteralComputedProperties: true,
objectLiteralDuplicateProperties: true,
objectLiteralShorthandMethods: true,
objectLiteralShorthandProperties: true,
octalLiterals: true,
regexUFlag: true,
regexYFlag: true,
restParams: true,
spread: true,
superInFunctions: true,
templateStrings: true,
unicodeCodePointEscapes: true,
globalReturn: true,
jsx: true,
experimentalObjectRestSpread: true
};

var messages = eslint.linter.verify(
code,
{
parser: require.resolve(".."),
rules: rules,
env: {
node: true
}
},
ecmaFeatures: features || defaultEcmaFeatures
}
);

Expand Down Expand Up @@ -111,11 +139,12 @@ describe("verify", function () {
});

// fix after updating to ESLint 1.0.0
it("Arrow function with non-block bodies (issue #20)", function () {
it.skip("Arrow function with non-block bodies (issue #20)", function () {
verifyAndAssertMessages(
"\"use strict\"; () => 1",
{ "strict": [1, "global"] },
[]
[],
{ modules: false }
);
});

Expand Down Expand Up @@ -1328,4 +1357,15 @@ describe("verify", function () {
[ ]
)
});

it("no-use-before-define #192", function () {
verifyAndAssertMessages(
[
"console.log(x);",
"var x = 1;"
].join("\n"),
{ "no-use-before-define": 1 },
[ "1:13 x was used before it was defined no-use-before-define" ]
)
});
});

0 comments on commit d2e3862

Please sign in to comment.