From 644aa3ed4ebedad4217d8570a8441c2db7f183d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:40:00 -0700 Subject: [PATCH] Sync hamming tests (#289) --- exercises/practice/hamming/.meta/example.vim | 2 +- exercises/practice/hamming/hamming.vader | 65 ++++++++++++-------- exercises/practice/hamming/hamming.vim | 2 +- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/exercises/practice/hamming/.meta/example.vim b/exercises/practice/hamming/.meta/example.vim index 1ab1f2c..4a02787 100644 --- a/exercises/practice/hamming/.meta/example.vim +++ b/exercises/practice/hamming/.meta/example.vim @@ -8,7 +8,7 @@ " function! Distance(strand1, strand2) if len(a:strand1) != len(a:strand2) - throw 'left and right strands must be of equal length' + throw 'strands must be of equal length' endif let distance = 0 for i in range(len(a:strand1)) diff --git a/exercises/practice/hamming/hamming.vader b/exercises/practice/hamming/hamming.vader index 9b249b2..4a97405 100644 --- a/exercises/practice/hamming/hamming.vader +++ b/exercises/practice/hamming/hamming.vader @@ -1,47 +1,58 @@ -" -" Version: 2.2.0 -" Execute (empty strands): - let strand1 = "" - let strand2 = "" - let expected = 0 - AssertEqual expected, Distance(strand1, strand2) + let g:strand1 = "" + let g:strand2 = "" + let g:expected = 0 + AssertEqual g:expected, Distance(g:strand1, g:strand2) Execute (single letter identical strands): - let strand1 = "A" - let strand2 = "A" - let expected = 0 - AssertEqual expected, Distance(strand1, strand2) + let g:strand1 = "A" + let g:strand2 = "A" + let g:expected = 0 + AssertEqual g:expected, Distance(g:strand1, g:strand2) Execute (single letter different strands): - let strand1 = "G" - let strand2 = "T" - let expected = 1 - AssertEqual expected, Distance(strand1, strand2) + let g:strand1 = "G" + let g:strand2 = "T" + let g:expected = 1 + AssertEqual g:expected, Distance(g:strand1, g:strand2) Execute (long identical strands): - let strand1 = "GGACTGAAATCTG" - let strand2 = "GGACTGAAATCTG" - let expected = 0 - AssertEqual expected, Distance(strand1, strand2) + let g:strand1 = "GGACTGAAATCTG" + let g:strand2 = "GGACTGAAATCTG" + let g:expected = 0 + AssertEqual g:expected, Distance(g:strand1, g:strand2) Execute (long different strands): - let strand1 = "GGACGGATTCTG" - let strand2 = "AGGACGGATTCT" - let expected = 9 - AssertEqual expected, Distance(strand1, strand2) + let g:strand1 = "GGACGGATTCTG" + let g:strand2 = "AGGACGGATTCT" + let g:expected = 9 + AssertEqual g:expected, Distance(g:strand1, g:strand2) Execute (disallow first strand longer): let g:strand1 = "AATG" let g:strand2 = "AAA" - let expected = 'left and right strands must be of equal length' + let g:expected = "strands must be of equal length" AssertThrows call Distance(g:strand1, g:strand2) - AssertEqual expected, g:vader_exception + AssertEqual g:expected, g:vader_exception Execute (disallow second strand longer): let g:strand1 = "ATA" let g:strand2 = "AGTG" - let expected = 'left and right strands must be of equal length' + let g:expected = "strands must be of equal length" AssertThrows call Distance(g:strand1, g:strand2) - AssertEqual expected, g:vader_exception + AssertEqual g:expected, g:vader_exception + +Execute (disallow empty first strand): + let g:strand1 = "" + let g:strand2 = "G" + let g:expected = "strands must be of equal length" + AssertThrows call Distance(g:strand1, g:strand2) + AssertEqual g:expected, g:vader_exception + +Execute (disallow empty second strand): + let g:strand1 = "G" + let g:strand2 = "" + let g:expected = "strands must be of equal length" + AssertThrows call Distance(g:strand1, g:strand2) + AssertEqual g:expected, g:vader_exception diff --git a/exercises/practice/hamming/hamming.vim b/exercises/practice/hamming/hamming.vim index 8f949b1..ad12d2a 100644 --- a/exercises/practice/hamming/hamming.vim +++ b/exercises/practice/hamming/hamming.vim @@ -4,7 +4,7 @@ " " If the lengths of the strands don't match, throw this exception: " -" 'left and right strands must be of equal length' +" 'strands must be of equal length' " function! Distance(strand1, strand2)