-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29ef81e
commit 2c0c669
Showing
3 changed files
with
64 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
const {TestTrees} = require("./test_trees.js"); | ||
const {TestUtils} = require("./test_utils.js"); | ||
|
||
function run_test_class(cls) { | ||
describe(cls.constructor.name, function() { | ||
describe(cls.constructor.name, function() { | ||
|
||
let test = new cls(); | ||
test.setUp(); | ||
let test_names = Object.getOwnPropertyNames(cls.prototype).filter((prop) => prop.startsWith("test_")) | ||
for (const name of test_names) { | ||
it(name, () => {test[name]()}) | ||
} | ||
}); | ||
let test = new cls(); | ||
if (test.setUp) { | ||
test.setUp(); | ||
} | ||
let test_names = Object.getOwnPropertyNames(cls.prototype).filter((prop) => prop.startsWith("test_")) | ||
for (const name of test_names) { | ||
it(name, () => {test[name]()}) | ||
} | ||
}); | ||
} | ||
|
||
run_test_class(TestTrees); | ||
run_test_class(TestTrees); | ||
run_test_class(TestUtils); |
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,49 @@ | ||
const _ = require("lodash"); | ||
const lark = require("../larkjs/lark.js"); | ||
const assert = require('assert'); | ||
|
||
const { | ||
isupper, | ||
} = lark; | ||
|
||
class TestCase { | ||
assertEqual(a, b) { | ||
assert(_.isEqual(a, b), "Not equal:", a, b); | ||
} | ||
} | ||
|
||
class TestUtils extends TestCase { | ||
test_is_upper_ignore_0() { | ||
this.assertEqual(isupper('__IGNORE_0'), true); | ||
} | ||
|
||
test_is_upper_hello() { | ||
this.assertEqual(isupper('HELLO'), true); | ||
} | ||
|
||
test_is_upper_foo_bar() { | ||
this.assertEqual(isupper('FOO_BAR'), true); | ||
} | ||
|
||
test_is_upper_foo_bar_baz() { | ||
this.assertEqual(isupper('FOO-BAR BAZ'), true); | ||
} | ||
|
||
test_is_upper_hello_lowercase() { | ||
this.assertEqual(isupper('Hello'), false); | ||
} | ||
|
||
test_is_upper_hell_o_uppercase() { | ||
this.assertEqual(isupper('HellO'), false); | ||
} | ||
|
||
test_is_upper_single_digit() { | ||
this.assertEqual(isupper('0'), false); | ||
} | ||
|
||
test_is_upper_numbers() { | ||
this.assertEqual(isupper('123'), false); | ||
} | ||
} | ||
|
||
module.exports = { TestUtils }; |