Skip to content

Commit

Permalink
#48 add test cases for set expansion with a range operator
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hitchins-ekkosense committed Jul 4, 2024
1 parent c57d89e commit 1b7e40b
Showing 1 changed file with 88 additions and 1 deletion.
89 changes: 88 additions & 1 deletion test/bash-expanded-sets.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,94 @@ describe('bash - expanded brace sets', () => {
['f{x,y{{g}}h', {}, ['f{x,y{{g}}h']],
['a{b{c{d,e}f{x,y{}g}h', {}, ['a{b{cdfxh', 'a{b{cdfy{}gh', 'a{b{cefxh', 'a{b{cefy{}gh']],
['f{x,y{}g}h', {}, ['fxh', 'fy{}gh']],
['z{a,b{,c}d', {}, ['z{a,bd', 'z{a,bcd']]
['z{a,b{,c}d', {}, ['z{a,bd', 'z{a,bcd']],

'should expand sets containing the range operator',

['{..a,b}', {}, ['..a', 'b']],
['{b,..a}', {}, ['b', '..a']],
['{a..,b}', {}, ['a..', 'b']],
['{...,b}', {}, ['...', 'b']],
['{a,..,b}', {}, ['a', '..', 'b']],
['..{a,b}', {}, ['..a', '..b']],
['{{..,..},a,b}', {}, ['..', '..', 'a', 'b']],
['{{{..,..}a,b}c,d}', {}, ['..ac', '..ac', 'bc', 'd']],
['..{..,{..,{..,..}a,b}c,d}', {}, ['....', '....c', '....ac', '....ac', '..bc', '..d']],
['..', {}, ['..']],
['{,..}', {}, ['', '..']],
['{..,}', {}, ['..', '']],
['{..,..,..}', {}, ['..', '..', '..']],
['{...,..,..}', {}, ['...', '..', '..']],
['{..,...,..}', {}, ['..', '...', '..']],
['{./../.,../../}', {}, ['./../.', '../../']],
['{../../../,../../}', {}, ['../../../', '../../']],
['{...,...,...}', {}, ['...', '...', '...']],
['{.,..,.}', {}, ['.', '..', '.']],
[',{..,..,.},', {}, [',..,', ',..,', ',.,']],
['{1..2,3..4}', {}, ['1..2', '3..4']],
['{..2,3..4}', {}, ['..2', '3..4']],
['{1..,2}', {}, ['1..', '2']],
['{1..,..2..,..3}', {}, ['1..', '..2..', '..3']],
['..{1..3}', {}, ['..1', '..2', '..3']],
['..{1..3}{..,..}', {}, ['..1..', '..1..', '..2..', '..2..', '..3..', '..3..']],

'should not expand invalid sets containing the range operator',

['{..a,b', {}, ['{..a,b']],
['{b,..a', {}, ['{b,..a']],
['{a..,b', {}, ['{a..,b']],
['{...,b', {}, ['{...,b']],
['{a,..,b', {}, ['{a,..,b']],
['..{a,b', {}, ['..{a,b']],
['{{..,..},a,b', {}, ['{..,a,b', '{..,a,b']],
['{{{..,..}a,b}c,d', {}, ['{..ac,d', '{..ac,d', '{bc,d']],
['{{{..,..}a,bc,d}', {}, ['{..a', '{..a', '{bc', '{d']],
['..{..,{..,{..,..}a,b}c,d', {}, ['..{..,..c,d', '..{..,..ac,d', '..{..,..ac,d', '..{..,bc,d']],
['..', {}, ['..']],
['{,..', {}, ['{,..']],
['{..,', {}, ['{..,']],
['{..,..,..', {}, ['{..,..,..']],
['{...,..,..', {}, ['{...,..,..']],
['{..,...,..', {}, ['{..,...,..']],
['{./../.,../../', {}, ['{./../.,../../']],
['{../../../,../../', {}, ['{../../../,../../']],
['{...,...,...', {}, ['{...,...,...']],
['{.,..,.', {}, ['{.,..,.']],
[',{..,..,.},', {}, [',..,', ',..,', ',.,']],
['{1..2,3..4', {}, ['{1..2,3..4']],
['{..2,3..4', {}, ['{..2,3..4']],
['{1..,2', {}, ['{1..,2']],
['{1..,..2..,..3', {}, ['{1..,..2..,..3']],
['..{1..3', {}, ['..{1..3']],
['..{1..3}{..,..', {}, ['..1{..,..', '..2{..,..', '..3{..,..']],

['..a,b}', {}, ['..a,b}']],
['b,..a}', {}, ['b,..a}']],
['a..,b}', {}, ['a..,b}']],
['...,b}', {}, ['...,b}']],
['a,..,b}', {}, ['a,..,b}']],
['..a,b}', {}, ['..a,b}']],
['{..,..},a,b}', {}, ['..,a,b}', '..,a,b}']],
['{{..,..}a,b}c,d}', {}, ['..ac,d}', '..ac,d}', 'bc,d}']],
['....,{..,{..,..}a,b}c,d}', {}, ['....,..c,d}', '....,..ac,d}', '....,..ac,d}', '....,bc,d}']],
['..', {}, ['..']],
[',..}', {}, [',..}']],
['..,}', {}, ['..,}']],
['..,..,..}', {}, ['..,..,..}']],
['...,..,..}', {}, ['...,..,..}']],
['..,...,..}', {}, ['..,...,..}']],
['./../.,../../}', {}, ['./../.,../../}']],
['../../../,../../}', {}, ['../../../,../../}']],
['...,...,...}', {}, ['...,...,...}']],
['.,..,.}', {}, ['.,..,.}']],
[',..,..,.},', {}, [',..,..,.},']],
['1..2,3..4}', {}, ['1..2,3..4}']],
['..2,3..4}', {}, ['..2,3..4}']],
['1..,2}', {}, ['1..,2}']],
['1..,..2..,..3}', {}, ['1..,..2..,..3}']],
['..1..3}', {}, ['..1..3}']],
['..1..3}{..,..}', {}, ['..1..3}..', '..1..3}..']],

];

fixtures.forEach(arr => {
Expand Down

0 comments on commit 1b7e40b

Please sign in to comment.