trackler 2.1.0.27 → 2.1.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/CONTRIBUTING.md +9 -349
- data/common/exercises/forth/canonical-data.json +1 -7
- data/lib/trackler/version.rb +1 -1
- data/tracks/bash/config.json +5 -0
- data/tracks/bash/exercises/anagram/anagram_tests.sh +99 -0
- data/tracks/bash/exercises/anagram/example.sh +23 -0
- data/tracks/delphi/config.json +8 -1
- data/tracks/delphi/exercises/two-fer/twofer.dpr +60 -0
- data/tracks/delphi/exercises/two-fer/utwoferExample.pas +17 -0
- data/tracks/delphi/exercises/two-fer/utwoferTest.pas +71 -0
- data/tracks/dlang/README.md +9 -5
- data/tracks/dlang/bin/test-exercise +14 -5
- data/tracks/dlang/docs/INSTALLATION.md +24 -0
- data/tracks/dlang/docs/TESTS.md +6 -6
- data/tracks/dlang/exercises/bob/dub.sdl +2 -0
- data/tracks/dlang/exercises/bob/{bob_example.d → example/bob.d} +0 -5
- data/tracks/dlang/exercises/bob/{bob.d → source/bob.d} +0 -5
- data/tracks/dlang/exercises/circular-buffer/dub.sdl +2 -0
- data/tracks/dlang/exercises/circular-buffer/{circular_buffer_example.d → example/circular_buffer.d} +0 -5
- data/tracks/dlang/exercises/circular-buffer/{circular_buffer.d → source/circular_buffer.d} +0 -5
- data/tracks/dlang/exercises/crypto-square/dub.sdl +2 -0
- data/tracks/dlang/exercises/crypto-square/{crypto_square_example.d → example/crypto_square.d} +0 -5
- data/tracks/dlang/exercises/crypto-square/{crypto_square.d → source/crypto_square.d} +0 -5
- data/tracks/dlang/exercises/difference-of-squares/dub.sdl +2 -0
- data/tracks/dlang/exercises/difference-of-squares/{difference_of_squares_example.d → example/difference_of_squares.d} +0 -2
- data/tracks/dlang/exercises/difference-of-squares/{difference_of_squares.d → source/difference_of_squares.d} +0 -2
- data/tracks/dlang/exercises/etl/dub.sdl +2 -0
- data/tracks/dlang/exercises/etl/{etl_example.d → example/etl.d} +0 -5
- data/tracks/dlang/exercises/etl/{etl.d → source/etl.d} +0 -5
- data/tracks/dlang/exercises/gigasecond/dub.sdl +2 -0
- data/tracks/dlang/exercises/gigasecond/{gigasecond_example.d → example/gigasecond.d} +0 -2
- data/tracks/dlang/exercises/gigasecond/{gigasecond.d → source/gigasecond.d} +0 -2
- data/tracks/dlang/exercises/hamming/dub.sdl +2 -0
- data/tracks/dlang/exercises/hamming/{hamming_example.d → example/hamming.d} +0 -5
- data/tracks/dlang/exercises/hamming/{hamming.d → source/hamming.d} +0 -5
- data/tracks/dlang/exercises/hello-world/dub.sdl +2 -0
- data/tracks/dlang/exercises/hello-world/{hello_world_example.d → example/hello_world.d} +0 -2
- data/tracks/dlang/exercises/hello-world/{hello_world.d → source/hello_world.d} +0 -0
- data/tracks/dlang/exercises/leap/dub.sdl +2 -0
- data/tracks/dlang/exercises/leap/{leap_example.d → example/leap.d} +0 -2
- data/tracks/dlang/exercises/leap/{leap.d → source/leap.d} +0 -2
- data/tracks/dlang/exercises/nucleotide-count/dub.sdl +2 -0
- data/tracks/dlang/exercises/nucleotide-count/{nucleotide_count_example.d → example/nucleotide_count.d} +0 -4
- data/tracks/dlang/exercises/nucleotide-count/{nucleotide_count.d → source/nucleotide_count.d} +0 -4
- data/tracks/dlang/exercises/pangram/dub.sdl +2 -0
- data/tracks/dlang/exercises/pangram/{pangram_example.d → example/pangram.d} +0 -2
- data/tracks/dlang/exercises/pangram/{pangram.d → source/pangram.d} +0 -2
- data/tracks/dlang/exercises/raindrops/dub.sdl +2 -0
- data/tracks/dlang/exercises/raindrops/{raindrops_example.d → example/raindrops.d} +0 -2
- data/tracks/dlang/exercises/raindrops/{raindrops.d → source/raindrops.d} +0 -2
- data/tracks/dlang/exercises/react/dub.sdl +2 -0
- data/tracks/dlang/exercises/react/{react_example.d → example/react.d} +0 -2
- data/tracks/dlang/exercises/react/{react.d → source/react.d} +0 -2
- data/tracks/dlang/exercises/rna-transcription/dub.sdl +2 -0
- data/tracks/dlang/exercises/rna-transcription/{rna_transcription_example.d → example/rna_transcription.d} +0 -2
- data/tracks/dlang/exercises/rna-transcription/{rna_transcription.d → source/rna_transcription.d} +0 -2
- data/tracks/dlang/exercises/robot-name/dub.sdl +2 -0
- data/tracks/dlang/exercises/robot-name/{robot_name_example.d → example/robot_name.d} +0 -5
- data/tracks/dlang/exercises/robot-name/{robot_name.d → source/robot_name.d} +0 -4
- data/tracks/dlang/exercises/roman-numerals/dub.sdl +2 -0
- data/tracks/dlang/exercises/roman-numerals/{roman_numerals_example.d → example/roman_numerals.d} +0 -4
- data/tracks/dlang/exercises/roman-numerals/{roman_numerals.d → source/roman_numerals.d} +0 -4
- data/tracks/dlang/exercises/series/dub.sdl +2 -0
- data/tracks/dlang/exercises/series/{series_example.d → example/series.d} +0 -5
- data/tracks/dlang/exercises/series/{series.d → source/series.d} +0 -5
- data/tracks/dlang/exercises/triangle/dub.sdl +2 -0
- data/tracks/dlang/exercises/triangle/{triangle_example.d → example/triangle.d} +0 -5
- data/tracks/dlang/exercises/triangle/{triangle.d → source/triangle.d} +0 -5
- data/tracks/elisp/.github/stale.yml +0 -0
- data/tracks/elisp/exercises/grains/grains-test.el +12 -12
- data/tracks/elisp/exercises/robot-name/robot-name-test.el +8 -19
- data/tracks/elisp/exercises/word-count/word-count-test.el +27 -27
- data/tracks/fortran/Makefile +3 -2
- data/tracks/fortran/config.json +21 -2
- data/tracks/fortran/exercises/difference-of-squares/difference_of_squares.fun +42 -0
- data/tracks/fortran/exercises/difference-of-squares/example.f90 +35 -0
- data/tracks/fortran/exercises/{hello_world → hello-world}/example.f90 +0 -0
- data/tracks/fortran/exercises/{hello_world → hello-world}/hello_world.fun +0 -0
- data/tracks/fortran/exercises/raindrops/example.f90 +26 -0
- data/tracks/fortran/exercises/raindrops/raindrops.fun +78 -0
- data/tracks/fortran/exercises/rna-transcription/example.f90 +27 -0
- data/tracks/fortran/exercises/rna-transcription/rna_transcription.fun +38 -0
- data/tracks/go/exercises/acronym/.meta/gen.go +51 -0
- data/tracks/go/exercises/acronym/acronym_test.go +1 -15
- data/tracks/go/exercises/acronym/cases_test.go +37 -0
- data/tracks/go/exercises/acronym/example.go +1 -1
- data/tracks/go/exercises/secret-handshake/.meta/gen.go +49 -0
- data/tracks/go/exercises/secret-handshake/cases_test.go +24 -0
- data/tracks/go/exercises/secret-handshake/example.go +1 -1
- data/tracks/go/exercises/secret-handshake/secret_handshake_test.go +1 -17
- data/tracks/java/config.json +23 -23
- data/tracks/java/exercises/book-store/src/example/java/{Bookstore.java → BookStore.java} +5 -12
- data/tracks/java/exercises/book-store/src/test/java/BookStoreTest.java +113 -0
- data/tracks/java/exercises/saddle-points/src/example/java/Matrix.java +5 -4
- data/tracks/java/exercises/saddle-points/src/example/java/MatrixCoordinate.java +5 -5
- data/tracks/java/exercises/saddle-points/src/main/java/MatrixCoordinate.java +5 -5
- data/tracks/java/exercises/saddle-points/src/test/java/MatrixTest.java +10 -10
- data/tracks/purescript/config.json +7 -0
- data/tracks/purescript/exercises/hamming/bower.json +16 -0
- data/tracks/purescript/exercises/hamming/examples/src/Hamming.purs +14 -0
- data/tracks/purescript/exercises/hamming/test/Main.purs +46 -0
- data/tracks/scala/config.json +7 -0
- data/tracks/scala/exercises/bob/example.scala +3 -3
- data/tracks/scala/exercises/bob/src/main/scala/Bob.scala +2 -2
- data/tracks/scala/exercises/bob/src/test/scala/BobTest.scala +83 -53
- data/tracks/scala/exercises/book-store/build.sbt +3 -0
- data/tracks/scala/exercises/book-store/example.scala +49 -0
- data/tracks/scala/exercises/book-store/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/book-store/src/test/scala/BookStoreTest.scala +70 -0
- data/tracks/scala/exercises/difference-of-squares/example.scala +3 -3
- data/tracks/scala/exercises/difference-of-squares/src/main/scala/DifferenceOfSquares.scala +8 -0
- data/tracks/scala/exercises/difference-of-squares/src/test/scala/DifferenceOfSquaresTest.scala +49 -0
- data/tracks/scala/exercises/leap/example.scala +4 -3
- data/tracks/scala/exercises/leap/src/main/scala/Leap.scala +2 -2
- data/tracks/scala/exercises/leap/src/test/scala/LeapTest.scala +12 -20
- data/tracks/scala/exercises/raindrops/src/test/scala/RaindropsTest.scala +46 -35
- data/tracks/scala/testgen/src/main/scala/BobTestGenerator.scala +15 -0
- data/tracks/scala/testgen/src/main/scala/BookStoreTestGenerator.scala +15 -0
- data/tracks/scala/testgen/src/main/scala/DifferenceOfSquaresTestGenerator.scala +17 -0
- data/tracks/scala/testgen/src/main/scala/LeapTestGenerator.scala +15 -0
- data/tracks/scala/testgen/src/main/scala/RaindropsTestGenerator.scala +15 -0
- data/tracks/vimscript/config.json +5 -0
- data/tracks/vimscript/exercises/triangle/example.vim +28 -0
- data/tracks/vimscript/exercises/triangle/triangle.vader +92 -0
- data/tracks/vimscript/exercises/triangle/triangle.vim +24 -0
- metadata +93 -44
- data/tracks/java/exercises/book-store/src/test/java/BookstoreTest.java +0 -119
- data/tracks/scala/exercises/difference-of-squares/src/main/scala/Squares.scala +0 -8
- data/tracks/scala/exercises/difference-of-squares/src/test/scala/SquaresTest.scala +0 -56
@@ -0,0 +1,42 @@
|
|
1
|
+
test_suite difference_of_squares
|
2
|
+
|
3
|
+
setup
|
4
|
+
end setup
|
5
|
+
|
6
|
+
test square_of_sum_1
|
7
|
+
assert_equal( 1, square_of_sum(1) )
|
8
|
+
end test
|
9
|
+
|
10
|
+
Xtest square_of_sum_5
|
11
|
+
assert_equal( 225, square_of_sum(5) )
|
12
|
+
end test
|
13
|
+
|
14
|
+
Xtest square_of_sum_100
|
15
|
+
assert_equal( 25502500, square_of_sum(100) )
|
16
|
+
end test
|
17
|
+
|
18
|
+
Xtest sum_of_squares_1
|
19
|
+
assert_equal( 1, sum_of_squares(1) )
|
20
|
+
end test
|
21
|
+
|
22
|
+
Xtest sum_of_squares_5
|
23
|
+
assert_equal( 55, sum_of_squares(5) )
|
24
|
+
end test
|
25
|
+
|
26
|
+
Xtest sum_of_squares_100
|
27
|
+
assert_equal( 338350, sum_of_squares(100) )
|
28
|
+
end test
|
29
|
+
|
30
|
+
Xtest difference_of_squares_1
|
31
|
+
assert_equal( 0, difference(1) )
|
32
|
+
end test
|
33
|
+
|
34
|
+
Xtest difference_of_squares_5
|
35
|
+
assert_equal( 170, difference(5) )
|
36
|
+
end test
|
37
|
+
|
38
|
+
Xtest difference_of_squares_100
|
39
|
+
assert_equal( 25164150, difference(100) )
|
40
|
+
end test
|
41
|
+
|
42
|
+
end test_suite
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module difference_of_squares
|
2
|
+
contains
|
3
|
+
integer function square_of_sum(n)
|
4
|
+
implicit none
|
5
|
+
integer :: i,n
|
6
|
+
|
7
|
+
square_of_sum = 0
|
8
|
+
|
9
|
+
do i = 1,n
|
10
|
+
square_of_sum = square_of_sum + i
|
11
|
+
end do
|
12
|
+
|
13
|
+
square_of_sum = square_of_sum * square_of_sum
|
14
|
+
end function square_of_sum
|
15
|
+
|
16
|
+
integer function sum_of_squares(n)
|
17
|
+
implicit none
|
18
|
+
integer :: i, n
|
19
|
+
|
20
|
+
sum_of_squares = 0
|
21
|
+
|
22
|
+
do i = 1,n
|
23
|
+
sum_of_squares = sum_of_squares + i**2
|
24
|
+
end do
|
25
|
+
|
26
|
+
end function sum_of_squares
|
27
|
+
|
28
|
+
integer function difference(n)
|
29
|
+
implicit none
|
30
|
+
integer :: n
|
31
|
+
|
32
|
+
difference = square_of_sum(n) - sum_of_squares(n)
|
33
|
+
end function difference
|
34
|
+
|
35
|
+
end module difference_of_squares
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module raindrops
|
2
|
+
contains
|
3
|
+
function convert(i)
|
4
|
+
implicit none
|
5
|
+
integer :: i
|
6
|
+
character(20) :: convert
|
7
|
+
|
8
|
+
convert = ''
|
9
|
+
|
10
|
+
if ( mod(i,3) .eq. 0 ) then
|
11
|
+
convert = 'Pling'
|
12
|
+
end if
|
13
|
+
if ( mod(i,5) .eq. 0 ) then
|
14
|
+
convert = trim(convert)//'Plang'
|
15
|
+
end if
|
16
|
+
if ( mod(i,7) .eq. 0 ) then
|
17
|
+
convert = trim(convert)//'Plong'
|
18
|
+
end if
|
19
|
+
|
20
|
+
if (convert .eq. '') then
|
21
|
+
write( convert, '(i20)' ) i
|
22
|
+
convert = trim(adjustl(convert))
|
23
|
+
end if
|
24
|
+
|
25
|
+
end function convert
|
26
|
+
end module raindrops
|
@@ -0,0 +1,78 @@
|
|
1
|
+
test_suite raindrops
|
2
|
+
|
3
|
+
setup
|
4
|
+
end setup
|
5
|
+
|
6
|
+
test the_sound_for_1_is_1
|
7
|
+
assert_equal( '1', convert(1) )
|
8
|
+
end test
|
9
|
+
|
10
|
+
Xtest the_sound_for_3_is_pling
|
11
|
+
assert_equal( 'Pling', convert(3) )
|
12
|
+
end test
|
13
|
+
|
14
|
+
Xtest the_sound_for_5_is_plang
|
15
|
+
assert_equal( 'Plang', convert(5) )
|
16
|
+
end test
|
17
|
+
|
18
|
+
Xtest the_sound_for_7_is_plong
|
19
|
+
assert_equal( 'Plong', convert(7) )
|
20
|
+
end test
|
21
|
+
|
22
|
+
Xtest the_sound_for_6_is_pling_as_it_has_a_factor_3
|
23
|
+
assert_equal( 'Pling', convert(6) )
|
24
|
+
end test
|
25
|
+
|
26
|
+
Xtest two_to_the_power_3_does_not_make_a_raindrop_sound
|
27
|
+
assert_equal( '8', convert(8) )
|
28
|
+
end test
|
29
|
+
|
30
|
+
Xtest the_sound_for_9_is_pling_as_it_has_factor_3
|
31
|
+
assert_equal( 'Pling', convert(9) )
|
32
|
+
end test
|
33
|
+
|
34
|
+
Xtest the_sound_for_10_is_plang_as_it_has_a_factor_5
|
35
|
+
assert_equal( 'Plang', convert(10) )
|
36
|
+
end test
|
37
|
+
|
38
|
+
Xtest the_sound_for_14_is_plong_as_it_has_a_factor_of_7
|
39
|
+
assert_equal( 'Plong', convert(14) )
|
40
|
+
end test
|
41
|
+
|
42
|
+
Xtest the_sound_for_15_is_plingplang_as_it_has_factors_3_and_5
|
43
|
+
assert_equal( 'PlingPlang', convert(15) )
|
44
|
+
end test
|
45
|
+
|
46
|
+
Xtest the_sound_for_21_is_plingplong_as_it_has_factors_3_and_7
|
47
|
+
assert_equal( 'PlingPlong', convert(21) )
|
48
|
+
end test
|
49
|
+
|
50
|
+
Xtest the_sound_for_25_is_plang_as_it_has_a_factor_of_5
|
51
|
+
assert_equal( 'Plang', convert(25) )
|
52
|
+
end test
|
53
|
+
|
54
|
+
Xtest the_sound_for_27_is_pling_as_it_has_a_factor_of_3
|
55
|
+
assert_equal( 'Pling', convert(27) )
|
56
|
+
end test
|
57
|
+
|
58
|
+
Xtest the_sound_for_35_is_plangplong_as_it_has_factors_5_and_7
|
59
|
+
assert_equal( 'PlangPlong', convert(35) )
|
60
|
+
end test
|
61
|
+
|
62
|
+
Xtest the_sound_for_49_is_plong_as_it_has_a_factor_of_7
|
63
|
+
assert_equal( 'Plong', convert(49) )
|
64
|
+
end test
|
65
|
+
|
66
|
+
Xtest the_sound_for_105_is_plingplangplong
|
67
|
+
assert_equal( 'PlingPlangPlong', convert(105) )
|
68
|
+
end test
|
69
|
+
|
70
|
+
Xtest the_sound_for_3125_is_plang_as_it_has_a_factor_5
|
71
|
+
assert_equal( 'Plang', convert(3125) )
|
72
|
+
end test
|
73
|
+
|
74
|
+
Xtest the_sound_for_3131_is_3131
|
75
|
+
assert_equal( '3131', convert(3131) )
|
76
|
+
end test
|
77
|
+
|
78
|
+
end test_suite
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module rna_transcription
|
2
|
+
contains
|
3
|
+
function complement(dna)
|
4
|
+
implicit none
|
5
|
+
character(*) :: dna
|
6
|
+
character(len(dna)) :: complement
|
7
|
+
integer :: i
|
8
|
+
|
9
|
+
do i = 1,len(dna)
|
10
|
+
select case (dna(i:i))
|
11
|
+
case ('G')
|
12
|
+
complement(i:i) = 'C'
|
13
|
+
case ('C')
|
14
|
+
complement(i:i) = 'G'
|
15
|
+
case ('T')
|
16
|
+
complement(i:i) = 'A'
|
17
|
+
case ('A')
|
18
|
+
complement(i:i) = 'U'
|
19
|
+
case default
|
20
|
+
complement = ''
|
21
|
+
return
|
22
|
+
end select
|
23
|
+
end do
|
24
|
+
|
25
|
+
end function complement
|
26
|
+
end module rna_transcription
|
27
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
test_suite rna_transcription
|
2
|
+
|
3
|
+
setup
|
4
|
+
end setup
|
5
|
+
|
6
|
+
test rna_complement_of_cytosine_is_guanine
|
7
|
+
assert_equal( 'G', complement('C') )
|
8
|
+
end test
|
9
|
+
|
10
|
+
Xtest rna_complement_of_guanine_is_cytosine
|
11
|
+
assert_equal( 'C', complement('G') )
|
12
|
+
end test
|
13
|
+
|
14
|
+
Xtest rna_complement_of_thymine_is_adenine
|
15
|
+
assert_equal( 'A', complement('T') )
|
16
|
+
end test
|
17
|
+
|
18
|
+
Xtest rna_complement_of_adenine_is_uracil
|
19
|
+
assert_equal( 'U', complement('A') )
|
20
|
+
end test
|
21
|
+
|
22
|
+
Xtest rna_complement
|
23
|
+
assert_equal( 'UGCACCAGAAUU', complement('ACGTGGTCTTAA') )
|
24
|
+
end test
|
25
|
+
|
26
|
+
Xtest dna_correctly_handles_invalid_input
|
27
|
+
assert_equal( '', complement('U') )
|
28
|
+
end test
|
29
|
+
|
30
|
+
Xtest dna_correctly_handles_completely_invalid_input
|
31
|
+
assert_equal( '', complement('XXX') )
|
32
|
+
end test
|
33
|
+
|
34
|
+
Xtest dna_correctly_handles_partially_invalid_input
|
35
|
+
assert_equal( '', complement('ACGTXXXCTTAA') )
|
36
|
+
end test
|
37
|
+
|
38
|
+
end test_suite
|
@@ -0,0 +1,51 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"log"
|
5
|
+
"text/template"
|
6
|
+
|
7
|
+
"../../../gen"
|
8
|
+
)
|
9
|
+
|
10
|
+
func main() {
|
11
|
+
t, err := template.New("").Parse(tmpl)
|
12
|
+
if err != nil {
|
13
|
+
log.Fatal(err)
|
14
|
+
}
|
15
|
+
var j js
|
16
|
+
if err := gen.Gen("acronym", &j, t); err != nil {
|
17
|
+
log.Fatal(err)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
// The JSON structure we expect to be able to unmarshal into
|
22
|
+
type js struct {
|
23
|
+
Cases []struct {
|
24
|
+
Description string
|
25
|
+
Cases []struct {
|
26
|
+
Description string
|
27
|
+
Property string
|
28
|
+
Phrase string
|
29
|
+
Expected string
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
// template applied to above data structure generates the Go test cases
|
35
|
+
var tmpl = `package acronym
|
36
|
+
|
37
|
+
{{.Header}}
|
38
|
+
|
39
|
+
type acronymTest struct {
|
40
|
+
input string
|
41
|
+
expected string
|
42
|
+
}
|
43
|
+
|
44
|
+
var stringTestCases = []acronymTest {
|
45
|
+
{{range .J.Cases}} {{range .Cases}}{
|
46
|
+
input: {{printf "%q" .Phrase }},
|
47
|
+
expected: {{printf "%q" .Expected }},
|
48
|
+
},
|
49
|
+
{{end}}{{end}}
|
50
|
+
}
|
51
|
+
`
|
@@ -4,21 +4,7 @@ import (
|
|
4
4
|
"testing"
|
5
5
|
)
|
6
6
|
|
7
|
-
const targetTestVersion =
|
8
|
-
|
9
|
-
type testCase struct {
|
10
|
-
input string
|
11
|
-
expected string
|
12
|
-
}
|
13
|
-
|
14
|
-
var stringTestCases = []testCase{
|
15
|
-
{"Portable Network Graphics", "PNG"},
|
16
|
-
{"HyperText Markup Language", "HTML"},
|
17
|
-
{"Ruby on Rails", "ROR"},
|
18
|
-
{"PHP: Hypertext Preprocessor", "PHP"},
|
19
|
-
{"First In, First Out", "FIFO"},
|
20
|
-
{"Complementary metal-oxide semiconductor", "CMOS"},
|
21
|
-
}
|
7
|
+
const targetTestVersion = 3
|
22
8
|
|
23
9
|
func TestTestVersion(t *testing.T) {
|
24
10
|
if testVersion != targetTestVersion {
|
@@ -0,0 +1,37 @@
|
|
1
|
+
package acronym
|
2
|
+
|
3
|
+
// Source: exercism/x-common
|
4
|
+
// Commit: cae7ae1 acronym: remove test case with mixed-case phrase (#788)
|
5
|
+
// x-common version: 1.1.0
|
6
|
+
|
7
|
+
type acronymTest struct {
|
8
|
+
input string
|
9
|
+
expected string
|
10
|
+
}
|
11
|
+
|
12
|
+
var stringTestCases = []acronymTest{
|
13
|
+
{
|
14
|
+
input: "Portable Network Graphics",
|
15
|
+
expected: "PNG",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
input: "Ruby on Rails",
|
19
|
+
expected: "ROR",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
input: "First In, First Out",
|
23
|
+
expected: "FIFO",
|
24
|
+
},
|
25
|
+
{
|
26
|
+
input: "PHP: Hypertext Preprocessor",
|
27
|
+
expected: "PHP",
|
28
|
+
},
|
29
|
+
{
|
30
|
+
input: "GNU Image Manipulation Program",
|
31
|
+
expected: "GIMP",
|
32
|
+
},
|
33
|
+
{
|
34
|
+
input: "Complementary metal-oxide semiconductor",
|
35
|
+
expected: "CMOS",
|
36
|
+
},
|
37
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"log"
|
5
|
+
"text/template"
|
6
|
+
|
7
|
+
"../../../gen"
|
8
|
+
)
|
9
|
+
|
10
|
+
func main() {
|
11
|
+
t, err := template.New("").Parse(tmpl)
|
12
|
+
if err != nil {
|
13
|
+
log.Fatal(err)
|
14
|
+
}
|
15
|
+
var j js
|
16
|
+
if err := gen.Gen("secret-handshake", &j, t); err != nil {
|
17
|
+
log.Fatal(err)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
// The JSON structure we expect to be able to unmarshal into
|
22
|
+
type js struct {
|
23
|
+
Cases []struct {
|
24
|
+
Description string
|
25
|
+
Cases []struct {
|
26
|
+
Description string
|
27
|
+
Property string
|
28
|
+
Input uint
|
29
|
+
Expected []string
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
// template applied to above data structure generates the Go test cases
|
35
|
+
var tmpl = `package secret
|
36
|
+
|
37
|
+
{{.Header}}
|
38
|
+
|
39
|
+
type secretHandshakeTest struct {
|
40
|
+
code uint
|
41
|
+
h []string
|
42
|
+
}
|
43
|
+
|
44
|
+
var tests = []secretHandshakeTest {
|
45
|
+
{{range .J.Cases}} {{range .Cases}}{ {{ .Input }}, {{printf "%#v" .Expected }},
|
46
|
+
},
|
47
|
+
{{end}}{{end}}
|
48
|
+
}
|
49
|
+
`
|
@@ -0,0 +1,24 @@
|
|
1
|
+
package secret
|
2
|
+
|
3
|
+
// Source: exercism/x-common
|
4
|
+
// Commit: 69c8700 secret-handshake: remove tests for numbers > 31 (#794)
|
5
|
+
// x-common version: 1.1.0
|
6
|
+
|
7
|
+
type secretHandshakeTest struct {
|
8
|
+
code uint
|
9
|
+
h []string
|
10
|
+
}
|
11
|
+
|
12
|
+
var tests = []secretHandshakeTest{
|
13
|
+
{1, []string{"wink"}},
|
14
|
+
{2, []string{"double blink"}},
|
15
|
+
{4, []string{"close your eyes"}},
|
16
|
+
{8, []string{"jump"}},
|
17
|
+
{3, []string{"wink", "double blink"}},
|
18
|
+
{19, []string{"double blink", "wink"}},
|
19
|
+
{24, []string{"jump"}},
|
20
|
+
{16, []string{}},
|
21
|
+
{15, []string{"wink", "double blink", "close your eyes", "jump"}},
|
22
|
+
{31, []string{"jump", "close your eyes", "double blink", "wink"}},
|
23
|
+
{0, []string{}},
|
24
|
+
}
|