-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for rule no-trailing-whitespace
- Loading branch information
duaraghav8
committed
Apr 8, 2019
1 parent
74f031f
commit c2464e4
Showing
9 changed files
with
159 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/** | ||
* @fileoverview Tests for no-trailing-whitespace rule | ||
* @author Raghav Dua <duaraghav8@gmail.com> | ||
*/ | ||
|
||
"use strict"; | ||
|
||
|
||
const Solium = require("../../../../lib/solium"); | ||
|
||
const config = { | ||
"rules": { | ||
"no-trailing-whitespace": "error" | ||
} | ||
}; | ||
|
||
|
||
describe("[RULE] no-trailing-whitespace: Acceptances", () => { | ||
|
||
it("should accept lines having no trailing whitespaces", done => { | ||
const code = ` | ||
contract Foo { | ||
// a comment | ||
function baz() returns(uint) { | ||
/* | ||
another happy comment | ||
on multiple lines | ||
*/ | ||
callHelloWorld( | ||
100, /* another block comment */ | ||
"voila!", | ||
0x1892873871198 | ||
); | ||
} | ||
}`; | ||
|
||
Solium.lint(code, config).should.be.empty(); | ||
done(); | ||
}); | ||
|
||
it("should accept comments & blank lines with trailing whitespaces if they're ignored", done => { | ||
const configLocal = { | ||
"rules": { | ||
"no-trailing-whitespace": [ | ||
"error", | ||
{ "skipBlankLines": true, "ignoreComments": true } | ||
] | ||
} | ||
}; | ||
|
||
const code = ` | ||
\t\t \t | ||
contract Foo { | ||
// a comment | ||
function baz() returns(uint) { | ||
/* \t | ||
another happy comment | ||
on multiple lines\t | ||
*/ | ||
\t \t | ||
callHelloWorld( | ||
100, /* another block comment */ | ||
"voila!", | ||
\t | ||
0x1892873871198 | ||
); | ||
} // another line comment\t\t | ||
function /* hello */ bax() /* world */ returns(string) { /* this is a stretched \t | ||
comment */ | ||
return "hello"; | ||
} | ||
}`; | ||
|
||
Solium.lint(code, configLocal).should.be.empty(); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
|
||
describe("[RULE] no-trailing-whitespace: Rejections", () => { | ||
|
||
it("should reject code, comment & blank lines with trailing whitespaces", done => { | ||
const code = ` | ||
\t\t \t | ||
contract Foo { | ||
// a comment | ||
function baz() returns(uint) { | ||
/* \t | ||
another happy comment | ||
on multiple lines\t | ||
*/ | ||
\t \t | ||
callHelloWorld( | ||
100, /* another block comment */ | ||
"voila!", | ||
\t | ||
0x1892873871198\t | ||
); | ||
} // another line comment\t\t | ||
function /* hello */ bax() /* world */ returns(string) { /* this is a stretched \t | ||
comment */ | ||
return "hello"; | ||
} | ||
}`; | ||
|
||
Solium.lint(code, config).should.have.size(16); | ||
done(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters