From 663cba663ee9632da218d974819aa1aae9071d1e Mon Sep 17 00:00:00 2001 From: Georgy Perepechko Date: Sat, 26 Oct 2019 23:48:25 +0300 Subject: [PATCH] test shuffle and unique --- fixtures/shuffled_lowercase_expected/sortLines | 1 + .../shuffled_lowercase_expected/sortLinesCaseInsensitive | 1 + fixtures/shuffled_lowercase_expected/sortLinesLineLength | 1 + .../sortLinesLineLengthReverse | 1 + fixtures/shuffled_lowercase_expected/sortLinesNatural | 1 + fixtures/shuffled_lowercase_expected/sortLinesReverse | 1 + fixtures/shuffled_lowercase_expected/sortLinesShuffle | 9 +++++++++ .../shuffled_lowercase_expected/sortLinesVariableLength | 1 + .../sortLinesVariableLengthReverse | 1 + fixtures/shuffled_lowercase_fixture | 1 + fixtures/variables_expected/sortLines | 1 + fixtures/variables_expected/sortLinesCaseInsensitive | 1 + fixtures/variables_expected/sortLinesLineLength | 1 + fixtures/variables_expected/sortLinesLineLengthReverse | 1 + fixtures/variables_expected/sortLinesNatural | 1 + fixtures/variables_expected/sortLinesReverse | 1 + fixtures/variables_expected/sortLinesShuffle | 4 ++++ fixtures/variables_expected/sortLinesVariableLength | 1 + .../variables_expected/sortLinesVariableLengthReverse | 1 + fixtures/variables_fixture | 3 ++- src/test/sort-lines.test.ts | 5 +++-- 21 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 fixtures/shuffled_lowercase_expected/sortLinesShuffle create mode 100644 fixtures/variables_expected/sortLinesShuffle diff --git a/fixtures/shuffled_lowercase_expected/sortLines b/fixtures/shuffled_lowercase_expected/sortLines index e84389d..392bd85 100644 --- a/fixtures/shuffled_lowercase_expected/sortLines +++ b/fixtures/shuffled_lowercase_expected/sortLines @@ -5,4 +5,5 @@ bb c cc d +dd dd \ No newline at end of file diff --git a/fixtures/shuffled_lowercase_expected/sortLinesCaseInsensitive b/fixtures/shuffled_lowercase_expected/sortLinesCaseInsensitive index e84389d..392bd85 100644 --- a/fixtures/shuffled_lowercase_expected/sortLinesCaseInsensitive +++ b/fixtures/shuffled_lowercase_expected/sortLinesCaseInsensitive @@ -5,4 +5,5 @@ bb c cc d +dd dd \ No newline at end of file diff --git a/fixtures/shuffled_lowercase_expected/sortLinesLineLength b/fixtures/shuffled_lowercase_expected/sortLinesLineLength index 7dfc46e..bd5e2dc 100644 --- a/fixtures/shuffled_lowercase_expected/sortLinesLineLength +++ b/fixtures/shuffled_lowercase_expected/sortLinesLineLength @@ -5,4 +5,5 @@ a cc aa bb +dd dd \ No newline at end of file diff --git a/fixtures/shuffled_lowercase_expected/sortLinesLineLengthReverse b/fixtures/shuffled_lowercase_expected/sortLinesLineLengthReverse index a7c609b..138204a 100644 --- a/fixtures/shuffled_lowercase_expected/sortLinesLineLengthReverse +++ b/fixtures/shuffled_lowercase_expected/sortLinesLineLengthReverse @@ -2,6 +2,7 @@ cc aa bb dd +dd d c b diff --git a/fixtures/shuffled_lowercase_expected/sortLinesNatural b/fixtures/shuffled_lowercase_expected/sortLinesNatural index e84389d..392bd85 100644 --- a/fixtures/shuffled_lowercase_expected/sortLinesNatural +++ b/fixtures/shuffled_lowercase_expected/sortLinesNatural @@ -5,4 +5,5 @@ bb c cc d +dd dd \ No newline at end of file diff --git a/fixtures/shuffled_lowercase_expected/sortLinesReverse b/fixtures/shuffled_lowercase_expected/sortLinesReverse index c3d0a9a..5f1139e 100644 --- a/fixtures/shuffled_lowercase_expected/sortLinesReverse +++ b/fixtures/shuffled_lowercase_expected/sortLinesReverse @@ -1,4 +1,5 @@ dd +dd d cc c diff --git a/fixtures/shuffled_lowercase_expected/sortLinesShuffle b/fixtures/shuffled_lowercase_expected/sortLinesShuffle new file mode 100644 index 0000000..4736f80 --- /dev/null +++ b/fixtures/shuffled_lowercase_expected/sortLinesShuffle @@ -0,0 +1,9 @@ +dd +dd +a +bb +b +c +aa +d +cc \ No newline at end of file diff --git a/fixtures/shuffled_lowercase_expected/sortLinesVariableLength b/fixtures/shuffled_lowercase_expected/sortLinesVariableLength index 7dfc46e..bd5e2dc 100644 --- a/fixtures/shuffled_lowercase_expected/sortLinesVariableLength +++ b/fixtures/shuffled_lowercase_expected/sortLinesVariableLength @@ -5,4 +5,5 @@ a cc aa bb +dd dd \ No newline at end of file diff --git a/fixtures/shuffled_lowercase_expected/sortLinesVariableLengthReverse b/fixtures/shuffled_lowercase_expected/sortLinesVariableLengthReverse index 970e487..aba0209 100644 --- a/fixtures/shuffled_lowercase_expected/sortLinesVariableLengthReverse +++ b/fixtures/shuffled_lowercase_expected/sortLinesVariableLengthReverse @@ -1,4 +1,5 @@ dd +dd bb aa cc diff --git a/fixtures/shuffled_lowercase_fixture b/fixtures/shuffled_lowercase_fixture index 52dfa76..1d7124f 100644 --- a/fixtures/shuffled_lowercase_fixture +++ b/fixtures/shuffled_lowercase_fixture @@ -5,4 +5,5 @@ c b bb a +dd dd \ No newline at end of file diff --git a/fixtures/variables_expected/sortLines b/fixtures/variables_expected/sortLines index 405f342..dae2427 100644 --- a/fixtures/variables_expected/sortLines +++ b/fixtures/variables_expected/sortLines @@ -1,3 +1,4 @@ var test10 = 1; var test100 = 100; +var test2 = 1221134; var test2 = 1221134; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesCaseInsensitive b/fixtures/variables_expected/sortLinesCaseInsensitive index 405f342..dae2427 100644 --- a/fixtures/variables_expected/sortLinesCaseInsensitive +++ b/fixtures/variables_expected/sortLinesCaseInsensitive @@ -1,3 +1,4 @@ var test10 = 1; var test100 = 100; +var test2 = 1221134; var test2 = 1221134; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesLineLength b/fixtures/variables_expected/sortLinesLineLength index 405f342..dae2427 100644 --- a/fixtures/variables_expected/sortLinesLineLength +++ b/fixtures/variables_expected/sortLinesLineLength @@ -1,3 +1,4 @@ var test10 = 1; var test100 = 100; +var test2 = 1221134; var test2 = 1221134; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesLineLengthReverse b/fixtures/variables_expected/sortLinesLineLengthReverse index 788ab3f..65ef899 100644 --- a/fixtures/variables_expected/sortLinesLineLengthReverse +++ b/fixtures/variables_expected/sortLinesLineLengthReverse @@ -1,3 +1,4 @@ var test2 = 1221134; +var test2 = 1221134; var test100 = 100; var test10 = 1; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesNatural b/fixtures/variables_expected/sortLinesNatural index 5976772..6c9950b 100644 --- a/fixtures/variables_expected/sortLinesNatural +++ b/fixtures/variables_expected/sortLinesNatural @@ -1,3 +1,4 @@ var test2 = 1221134; +var test2 = 1221134; var test10 = 1; var test100 = 100; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesReverse b/fixtures/variables_expected/sortLinesReverse index 788ab3f..65ef899 100644 --- a/fixtures/variables_expected/sortLinesReverse +++ b/fixtures/variables_expected/sortLinesReverse @@ -1,3 +1,4 @@ var test2 = 1221134; +var test2 = 1221134; var test100 = 100; var test10 = 1; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesShuffle b/fixtures/variables_expected/sortLinesShuffle new file mode 100644 index 0000000..faebbfe --- /dev/null +++ b/fixtures/variables_expected/sortLinesShuffle @@ -0,0 +1,4 @@ +var test2 = 1221134; +var test100 = 100; +var test2 = 1221134; +var test10 = 1; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesVariableLength b/fixtures/variables_expected/sortLinesVariableLength index 5976772..6c9950b 100644 --- a/fixtures/variables_expected/sortLinesVariableLength +++ b/fixtures/variables_expected/sortLinesVariableLength @@ -1,3 +1,4 @@ var test2 = 1221134; +var test2 = 1221134; var test10 = 1; var test100 = 100; \ No newline at end of file diff --git a/fixtures/variables_expected/sortLinesVariableLengthReverse b/fixtures/variables_expected/sortLinesVariableLengthReverse index 26ac871..4ea50bf 100644 --- a/fixtures/variables_expected/sortLinesVariableLengthReverse +++ b/fixtures/variables_expected/sortLinesVariableLengthReverse @@ -1,3 +1,4 @@ var test100 = 100; var test10 = 1; +var test2 = 1221134; var test2 = 1221134; \ No newline at end of file diff --git a/fixtures/variables_fixture b/fixtures/variables_fixture index ee15fea..b17447e 100644 --- a/fixtures/variables_fixture +++ b/fixtures/variables_fixture @@ -1,3 +1,4 @@ var test10 = 1; var test2 = 1221134; -var test100 = 100; \ No newline at end of file +var test100 = 100; +var test2 = 1221134; \ No newline at end of file diff --git a/src/test/sort-lines.test.ts b/src/test/sort-lines.test.ts index 5088e25..df5c5b6 100644 --- a/src/test/sort-lines.test.ts +++ b/src/test/sort-lines.test.ts @@ -20,10 +20,11 @@ function getAllText(document: TextDocument): string { const fixtureDir = path.join(__dirname, '..', '..', 'fixtures'); const fixtures = fs.readdirSync(fixtureDir).filter(v => v.search('_fixture$') !== -1).map(f => f.replace('_fixture', '')); const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf8')); -const nonDeterministicCommands = ['sortLinesShuffle']; -const extCommands: string[] = packageJson.contributes.commands.map(c => c.command.replace('sortLines.', '')).filter(c => nonDeterministicCommands.indexOf(c) === -1); +const extCommands: string[] = packageJson.contributes.commands.map(c => c.command.replace('sortLines.', '')); const expectedExists: { [fixture: string]: { [command: string]: boolean } } = {}; +Math.random = function(): 0.9 { return 0.9; }; + suite('Sort Lines', () => { suite('All command fixtures exist', () => { fixtures.forEach(fixture => {