Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Sep 6, 2018
1 parent f112879 commit 0136700
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions lib/aslGrammar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,46 +178,34 @@ describe('Value modifiers', () => {
})

describe('Form', () => {
testEach(
[createSign(), {forms: []}],
[createSign(['@form ~a LAK328', '@end form']), {
forms: [
createForm({variant: 'a', sign: 'LAK328'})
]
}],
[createSign(['@form ~a A', '@note a note', '@end form']), {
forms: [
createForm({variant: 'a', sign: 'A', notes: ['a note']})
]
}],
[createSign(['@form ~a ASAL₂~a', '@end form']), {
forms: [
createForm({variant: 'a', sign: 'ASAL₂~a'})
]
}],
[createSign(['@form ~a A', '@v d', '@end form']), {
forms: [
createForm({variant: 'a', sign: 'A', ...createValues({value: 'd', subIndex: 1})})
]
}],
[createSign(['@form ~a A', '@v d', '@note a note', '@end form']), {
forms: [
createForm({variant: 'a', sign: 'A', ...createValues({value: 'd', subIndex: 1, notes: ['a note']})})
]
}],
[createSign(['@v a', '@form ~a A', '@v d', '@end form']), {
test.each([
[[], {forms: []}],
[['@form ~a LAK328', '@end form'], {forms: [createForm({variant: 'a', sign: 'LAK328'})]}],
[['@form ~a A', '@note a note', '@end form'], {forms: [createForm({variant: 'a', sign: 'A', notes: ['a note']})]}],
[['@form ~a ASAL₂~a', '@end form'], {forms: [createForm({variant: 'a', sign: 'ASAL₂~a'})]}],
[['@form ~a A', '@v d', '@end form'], {forms: [createForm({
variant: 'a',
sign: 'A',
...createValues({value: 'd', subIndex: 1})
})]}],
[['@form ~a A', '@v d', '@note a note', '@end form'], {forms: [createForm({
variant: 'a',
sign: 'A',
...createValues({value: 'd', subIndex: 1, notes: ['a note']})
})]}],
[['@v a', '@form ~a A', '@v d', '@end form'], {
...createValues({value: 'a', subIndex: 1}),
forms: [
createForm({variant: 'a', sign: 'A', ...createValues({value: 'd', subIndex: 1})})
]
}],
[createSign(['@form ~a A', '@form ~b B']), {
[['@form ~a A', '@form ~b B'], {
forms: [
createForm({variant: 'a', sign: 'A'}),
createForm({variant: 'b', sign: 'B'})
]
}]
)
])('Evaluates forms %s', (sign, expected) => evaluates(createSign(sign), expected))
})

describe('Multiple signs', () => {
Expand All @@ -229,17 +217,13 @@ describe('Multiple signs', () => {
)
})

describe.each([
test.each([
'@uname X',
'@uphase 1',
'@inst instance',
'@pname A',
'#comment'
])('Tag "%s" is ignored', tag => {
testEach(
[createSign([tag]), {}]
)
})
])('Tag "%s" is ignored', tag => evaluates(createSign([tag]), {}))

describe.each([
'@nosign A\n@end sign',
Expand Down

0 comments on commit 0136700

Please sign in to comment.