Skip to content

Commit

Permalink
Fix remaining lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Oct 13, 2016
1 parent fd6a864 commit efa4786
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"plugins": [
"standard",
"promise"
]
],
"rules": {
"no-new-func": 0,
"space-before-function-paren": [2, "never"]
}
}
}
31 changes: 19 additions & 12 deletions src/make-plural.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,30 @@ class Tests {
}

testCond(n, type, expResult, fn) {
try { var r = (fn || this.obj.fn)(n, (type === 'ordinal')) }
catch (e) { r = e.toString() }
if (r !== expResult) { throw new Error(
'Locale ' + JSON.stringify(this.obj.lc) + type
+ ' rule self-test failed for v = ' + JSON.stringify(n)
+ ' (was ' + JSON.stringify(r) + ', expected ' + JSON.stringify(expResult) + ')'
) }
try {
var r = (fn || this.obj.fn)(n, (type === 'ordinal'))
} catch (e) {
r = e.toString()
}
if (r !== expResult) {
throw new Error(
'Locale ' + JSON.stringify(this.obj.lc) + type +
' rule self-test failed for v = ' + JSON.stringify(n) +
' (was ' + JSON.stringify(r) + ', expected ' + JSON.stringify(expResult) + ')'
)
}
return true
}

testCat(type, cat, fn) {
const data = this[type][cat]
if (!data.values) data.values = data.src.join(' ')
.replace(/^[ ,]+|[ ,]+$/g, '')
.replace(/(0\.[0-9])~(1\.[1-9])/g, '$1 1.0 $2')
.split(/[ ,~]+/)
data.values.forEach( n => {
if (!data.values) {
data.values = data.src.join(' ')
.replace(/^[ ,]+|[ ,]+$/g, '')
.replace(/(0\.[0-9])~(1\.[1-9])/g, '$1 1.0 $2')
.split(/[ ,~]+/)
}
data.values.forEach(n => {
this.testCond(n, type, cat, fn)
if (!/\.0+$/.test(n)) this.testCond(Number(n), type, cat, fn)
})
Expand Down

0 comments on commit efa4786

Please sign in to comment.