trackler 2.0.6.33 → 2.0.6.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/delphi/exercises/beer-song/inputdata.txt +7 -0
  4. data/tracks/delphi/exercises/beer-song/uBeerSongExample.pas +12 -12
  5. data/tracks/delphi/exercises/beer-song/uBeerSongTests.pas +74 -59
  6. data/tracks/elixir/exercises/grains/example.exs +3 -2
  7. data/tracks/elixir/exercises/grains/grains_test.exs +24 -8
  8. data/tracks/go/exercises/binary-search/binary_search_test.go +8 -0
  9. data/tracks/go/exercises/binary-search/example.go +2 -0
  10. data/tracks/go/exercises/binary/binary_test.go +5 -2
  11. data/tracks/go/exercises/variable-length-quantity/example.go +2 -0
  12. data/tracks/go/exercises/variable-length-quantity/variable_length_quantity_test.go +8 -0
  13. data/tracks/go/exercises/word-count/word_count_test.go +4 -1
  14. data/tracks/julia/config.json +26 -0
  15. data/tracks/julia/exercises/gigasecond/example.jl +1 -0
  16. data/tracks/julia/exercises/gigasecond/gigasecond.jl +3 -0
  17. data/tracks/julia/exercises/gigasecond/runtests.jl +15 -0
  18. data/tracks/julia/exercises/roman-numerals/example.jl +21 -0
  19. data/tracks/julia/exercises/roman-numerals/roman-numerals.jl +3 -0
  20. data/tracks/julia/exercises/roman-numerals/runtests.jl +37 -0
  21. data/tracks/julia/exercises/transpose/example.jl +20 -0
  22. data/tracks/julia/exercises/transpose/runtests.jl +212 -0
  23. data/tracks/julia/exercises/transpose/transpose.jl +3 -0
  24. data/tracks/kotlin/.travis.yml +5 -2
  25. data/tracks/kotlin/bin/{build.sh → unit-tests.sh} +8 -6
  26. data/tracks/kotlin/exercises/_template/build.gradle +6 -0
  27. data/tracks/kotlin/exercises/accumulate/build.gradle +6 -0
  28. data/tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt +7 -0
  29. data/tracks/kotlin/exercises/acronym/build.gradle +6 -0
  30. data/tracks/kotlin/exercises/acronym/src/test/kotlin/AcronymTest.kt +7 -0
  31. data/tracks/kotlin/exercises/allergies/build.gradle +6 -0
  32. data/tracks/kotlin/exercises/allergies/src/test/kotlin/AllergiesTest.kt +20 -0
  33. data/tracks/kotlin/exercises/anagram/build.gradle +6 -0
  34. data/tracks/kotlin/exercises/anagram/src/test/kotlin/AnagramTest.kt +11 -0
  35. data/tracks/kotlin/exercises/atbash-cipher/build.gradle +6 -0
  36. data/tracks/kotlin/exercises/atbash-cipher/src/test/kotlin/AtbashTest.kt +3 -0
  37. data/tracks/kotlin/exercises/beer-song/build.gradle +6 -0
  38. data/tracks/kotlin/exercises/beer-song/src/test/kotlin/BeerSongTest.kt +13 -0
  39. data/tracks/kotlin/exercises/binary-search/build.gradle +6 -0
  40. data/tracks/kotlin/exercises/binary-search/src/test/kotlin/BinarySearchTest.kt +9 -0
  41. data/tracks/kotlin/exercises/binary/build.gradle +6 -0
  42. data/tracks/kotlin/exercises/binary/src/test/kotlin/BinaryTest.kt +2 -0
  43. data/tracks/kotlin/exercises/bob/build.gradle +6 -0
  44. data/tracks/kotlin/exercises/bob/src/test/kotlin/BobTest.kt +19 -0
  45. data/tracks/kotlin/exercises/bracket-push/build.gradle +6 -0
  46. data/tracks/kotlin/exercises/bracket-push/src/test/kotlin/BracketPushTest.kt +2 -0
  47. data/tracks/kotlin/exercises/build.gradle +17 -1
  48. data/tracks/kotlin/exercises/change/build.gradle +6 -0
  49. data/tracks/kotlin/exercises/change/src/test/kotlin/ChangeTest.kt +9 -0
  50. data/tracks/kotlin/exercises/difference-of-squares/build.gradle +6 -0
  51. data/tracks/kotlin/exercises/difference-of-squares/src/test/kotlin/SquaresTest.kt +13 -1
  52. data/tracks/kotlin/exercises/etl/build.gradle +6 -0
  53. data/tracks/kotlin/exercises/etl/src/test/kotlin/ETLTest.kt +5 -0
  54. data/tracks/kotlin/exercises/flatten-array/build.gradle +6 -0
  55. data/tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt +9 -1
  56. data/tracks/kotlin/exercises/gigasecond/build.gradle +6 -0
  57. data/tracks/kotlin/exercises/gigasecond/src/test/kotlin/GigasecondTest.kt +6 -0
  58. data/tracks/kotlin/exercises/grade-school/build.gradle +6 -0
  59. data/tracks/kotlin/exercises/grade-school/src/test/kotlin/SchoolTest.kt +8 -0
  60. data/tracks/kotlin/exercises/hamming/build.gradle +6 -0
  61. data/tracks/kotlin/exercises/hamming/src/test/kotlin/HammingTest.kt +10 -0
  62. data/tracks/kotlin/exercises/hello-world/build.gradle +6 -0
  63. data/tracks/kotlin/exercises/hello-world/src/test/kotlin/HelloWorldTest.kt +6 -0
  64. data/tracks/kotlin/exercises/hexadecimal/build.gradle +6 -0
  65. data/tracks/kotlin/exercises/hexadecimal/src/test/kotlin/HexadecimalTest.kt +2 -0
  66. data/tracks/kotlin/exercises/isogram/build.gradle +6 -0
  67. data/tracks/kotlin/exercises/isogram/src/test/kotlin/IsogramTest.kt +2 -0
  68. data/tracks/kotlin/exercises/largest-series-product/build.gradle +6 -0
  69. data/tracks/kotlin/exercises/largest-series-product/src/test/kotlin/SeriesInvalidInputTest.kt +5 -0
  70. data/tracks/kotlin/exercises/largest-series-product/src/test/kotlin/SeriesValidInputTest.kt +2 -0
  71. data/tracks/kotlin/exercises/leap/build.gradle +6 -0
  72. data/tracks/kotlin/exercises/leap/src/test/kotlin/LeapTest.kt +8 -0
  73. data/tracks/kotlin/exercises/linked-list/build.gradle +6 -0
  74. data/tracks/kotlin/exercises/linked-list/src/test/kotlin/DequeTest.kt +6 -0
  75. data/tracks/kotlin/exercises/luhn/build.gradle +6 -0
  76. data/tracks/kotlin/exercises/luhn/src/test/kotlin/LuhnTest.kt +11 -0
  77. data/tracks/kotlin/exercises/nth-prime/build.gradle +6 -0
  78. data/tracks/kotlin/exercises/nth-prime/src/test/kotlin/PrimeTest.kt +6 -0
  79. data/tracks/kotlin/exercises/nucleotide-count/build.gradle +6 -0
  80. data/tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt +12 -1
  81. data/tracks/kotlin/exercises/pangram/build.gradle +6 -0
  82. data/tracks/kotlin/exercises/pangram/src/test/kotlin/PangramTest.kt +11 -0
  83. data/tracks/kotlin/exercises/pascals-triangle/build.gradle +6 -0
  84. data/tracks/kotlin/exercises/pascals-triangle/src/test/kotlin/PascalsTriangleTest.kt +5 -0
  85. data/tracks/kotlin/exercises/phone-number/build.gradle +6 -0
  86. data/tracks/kotlin/exercises/phone-number/src/test/kotlin/PhoneNumberTest.kt +9 -0
  87. data/tracks/kotlin/exercises/pig-latin/build.gradle +6 -0
  88. data/tracks/kotlin/exercises/pig-latin/src/test/kotlin/PigLatinTest.kt +2 -0
  89. data/tracks/kotlin/exercises/raindrops/build.gradle +6 -0
  90. data/tracks/kotlin/exercises/raindrops/src/test/kotlin/RaindropsTest.kt +2 -0
  91. data/tracks/kotlin/exercises/rna-transcription/build.gradle +6 -0
  92. data/tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt +8 -1
  93. data/tracks/kotlin/exercises/robot-name/build.gradle +6 -0
  94. data/tracks/kotlin/exercises/robot-name/src/test/kotlin/RobotTest.kt +4 -0
  95. data/tracks/kotlin/exercises/roman-numerals/build.gradle +6 -0
  96. data/tracks/kotlin/exercises/roman-numerals/src/test/kotlin/RomanNumeralTest.kt +2 -0
  97. data/tracks/kotlin/exercises/scrabble-score/build.gradle +6 -0
  98. data/tracks/kotlin/exercises/scrabble-score/src/test/kotlin/ScrabbleScoreTest.kt +2 -0
  99. data/tracks/kotlin/exercises/series/build.gradle +6 -0
  100. data/tracks/kotlin/exercises/series/src/test/kotlin/SeriesTest.kt +4 -0
  101. data/tracks/kotlin/exercises/sieve/build.gradle +6 -0
  102. data/tracks/kotlin/exercises/sieve/src/test/kotlin/SieveTest.kt +4 -0
  103. data/tracks/kotlin/exercises/simple-cipher/build.gradle +6 -0
  104. data/tracks/kotlin/exercises/simple-cipher/src/test/kotlin/IncorrectKeyCipherTest.kt +6 -0
  105. data/tracks/kotlin/exercises/simple-cipher/src/test/kotlin/RandomKeyCipherTest.kt +7 -0
  106. data/tracks/kotlin/exercises/simple-cipher/src/test/kotlin/SubstitutionCipherTest.kt +9 -0
  107. data/tracks/kotlin/exercises/space-age/build.gradle +6 -0
  108. data/tracks/kotlin/exercises/space-age/src/test/kotlin/SpaceAgeTest.kt +10 -0
  109. data/tracks/kotlin/exercises/strain/build.gradle +6 -0
  110. data/tracks/kotlin/exercises/strain/src/test/kotlin/StrainTest.kt +13 -0
  111. data/tracks/kotlin/exercises/word-count/build.gradle +6 -0
  112. data/tracks/kotlin/exercises/word-count/src/test/kotlin/WordCountTest.kt +8 -0
  113. data/tracks/objective-c/circle.yml +1 -1
  114. data/tracks/perl6/.travis.yml +2 -2
  115. data/tracks/perl6/config.json +5 -0
  116. data/tracks/perl6/docs/TESTS.md +78 -18
  117. data/tracks/perl6/exercises/allergies/{Example.p6 → Example.pm} +0 -0
  118. data/tracks/perl6/exercises/allergies/allergies.t +2 -7
  119. data/tracks/perl6/exercises/atbash-cipher/{Example.p6 → Example.pm} +0 -0
  120. data/tracks/perl6/exercises/atbash-cipher/cipher.t +2 -7
  121. data/tracks/perl6/exercises/linked-list/Example.pm6 +51 -0
  122. data/tracks/perl6/exercises/linked-list/linked-list.t +91 -0
  123. data/tracks/perl6/exercises/space-age/{Example.p6 → Example.pm} +0 -0
  124. data/tracks/perl6/exercises/space-age/space-age.t +2 -7
  125. data/tracks/perl6/exercises/trinary/{Example.p6 → Example.pm} +0 -0
  126. data/tracks/perl6/exercises/trinary/trinary.t +2 -7
  127. data/tracks/perl6/exercises/wordy/{Example.p6 → Example.pm} +0 -0
  128. data/tracks/perl6/exercises/wordy/wordy.t +2 -7
  129. data/tracks/pony/README.md +4 -27
  130. data/tracks/pony/config.json +16 -0
  131. data/tracks/pony/exercises/atbash-cipher/example.pony +40 -0
  132. data/tracks/pony/exercises/atbash-cipher/test.pony +67 -0
  133. data/tracks/pony/exercises/beer-song/example.pony +44 -0
  134. data/tracks/pony/exercises/beer-song/test.pony +27 -0
  135. data/tracks/pony/exercises/rna-transcription/test.pony +1 -1
  136. data/tracks/prolog/docs/INSTALLATION.md +1 -1
  137. data/tracks/prolog/docs/TESTS.md +2 -2
  138. metadata +24 -8
@@ -20,3 +20,9 @@ dependencies {
20
20
  testCompile 'junit:junit:4.12'
21
21
  testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
22
22
  }
23
+ test {
24
+ testLogging {
25
+ exceptionFormat = 'full'
26
+ events = ["passed", "failed", "skipped"]
27
+ }
28
+ }
@@ -1,8 +1,10 @@
1
1
  import org.junit.Test
2
+ import org.junit.Ignore
2
3
  import kotlin.test.assertEquals
3
4
 
4
5
  class StrainTest {
5
6
 
7
+
6
8
  @Test
7
9
  fun emptyKeep() {
8
10
  val input = emptyList<Int>()
@@ -10,6 +12,7 @@ class StrainTest {
10
12
  assertEquals(expectedOutput, Strain.keep(input, { it < 10 }))
11
13
  }
12
14
 
15
+ @Ignore
13
16
  @Test
14
17
  fun keepEverything() {
15
18
  val input = listOf(1, 2, 3)
@@ -17,6 +20,7 @@ class StrainTest {
17
20
  assertEquals(expectedOutput, Strain.keep(input, { it < 10 }))
18
21
  }
19
22
 
23
+ @Ignore
20
24
  @Test
21
25
  fun keepFirstAndLast() {
22
26
  val input = listOf(1, 2, 3)
@@ -24,6 +28,7 @@ class StrainTest {
24
28
  assertEquals(expectedOutput, Strain.keep(input, { it % 2 != 0 }))
25
29
  }
26
30
 
31
+ @Ignore
27
32
  @Test
28
33
  fun keepNeitherFirstNorLast() {
29
34
  val input = listOf(1, 2, 3, 4, 5)
@@ -31,6 +36,7 @@ class StrainTest {
31
36
  assertEquals(expectedOutput, Strain.keep(input, { it % 2 == 0 }))
32
37
  }
33
38
 
39
+ @Ignore
34
40
  @Test
35
41
  fun KeepStrings() {
36
42
  val words = "apple zebra banana zombies cherimoya zelot".split(" ")
@@ -39,6 +45,7 @@ class StrainTest {
39
45
  Strain.keep(words, { it.startsWith("z") }))
40
46
  }
41
47
 
48
+ @Ignore
42
49
  @Test
43
50
  fun keepArrays() {
44
51
  val actual = listOf(
@@ -58,6 +65,7 @@ class StrainTest {
58
65
  Strain.keep(actual, { col -> col.contains(5) }))
59
66
  }
60
67
 
68
+ @Ignore
61
69
  @Test
62
70
  fun emptyDiscard() {
63
71
  val input = emptyList<Int>()
@@ -65,6 +73,7 @@ class StrainTest {
65
73
  assertEquals(expectedOutput, Strain.discard(input, { it < 10 }))
66
74
  }
67
75
 
76
+ @Ignore
68
77
  @Test
69
78
  fun discardNothing() {
70
79
  val input = listOf(1, 2, 3)
@@ -72,6 +81,7 @@ class StrainTest {
72
81
  assertEquals(expectedOutput, Strain.discard(input, { it > 10 }))
73
82
  }
74
83
 
84
+ @Ignore
75
85
  @Test
76
86
  fun discardFirstAndLast() {
77
87
  val input = listOf(1, 2, 3)
@@ -80,6 +90,7 @@ class StrainTest {
80
90
 
81
91
  }
82
92
 
93
+ @Ignore
83
94
  @Test
84
95
  fun discardNeitherFirstNorLast() {
85
96
  val input = listOf(1, 2, 3, 4, 5)
@@ -87,6 +98,7 @@ class StrainTest {
87
98
  assertEquals(expectedOutput, Strain.discard(input, { it % 2 == 0 }))
88
99
  }
89
100
 
101
+ @Ignore
90
102
  @Test
91
103
  fun discardStrings() {
92
104
  val words = "apple zebra banana zombies cherimoya zelot".split(" ")
@@ -95,6 +107,7 @@ class StrainTest {
95
107
  Strain.discard(words, { it.startsWith("z") }))
96
108
  }
97
109
 
110
+ @Ignore
98
111
  @Test
99
112
  fun discardArrays() {
100
113
  val actual = listOf(
@@ -20,3 +20,9 @@ dependencies {
20
20
  testCompile 'junit:junit:4.12'
21
21
  testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
22
22
  }
23
+ test {
24
+ testLogging {
25
+ exceptionFormat = 'full'
26
+ events = ["passed", "failed", "skipped"]
27
+ }
28
+ }
@@ -1,8 +1,10 @@
1
1
  import org.junit.Test
2
+ import org.junit.Ignore
2
3
  import kotlin.test.assertEquals
3
4
 
4
5
  class WordCountTest {
5
6
 
7
+
6
8
  @Test
7
9
  fun countOneWord() {
8
10
  val expectedWordCount = mapOf("word" to 1)
@@ -10,6 +12,7 @@ class WordCountTest {
10
12
  assertEquals(expectedWordCount, WordCount.phrase("word"))
11
13
  }
12
14
 
15
+ @Ignore
13
16
  @Test
14
17
  fun countOneOfEach() {
15
18
  val expectedWordCount = mapOf("one" to 1, "of" to 1, "each" to 1)
@@ -17,6 +20,7 @@ class WordCountTest {
17
20
  assertEquals(expectedWordCount, WordCount.phrase("one of each"))
18
21
  }
19
22
 
23
+ @Ignore
20
24
  @Test
21
25
  fun countMultipleOccurences() {
22
26
  val expectedWordCount = mapOf("one" to 1, "fish" to 4, "two" to 1, "red" to 1, "blue" to 1)
@@ -24,6 +28,7 @@ class WordCountTest {
24
28
  assertEquals(expectedWordCount, WordCount.phrase("one fish two fish red fish blue fish"))
25
29
  }
26
30
 
31
+ @Ignore
27
32
  @Test
28
33
  fun ignorePunctuation() {
29
34
  val expectedWordCount = mapOf("car" to 1, "carpet" to 1, "as" to 1, "java" to 1, "javascript" to 1)
@@ -32,6 +37,7 @@ class WordCountTest {
32
37
 
33
38
  }
34
39
 
40
+ @Ignore
35
41
  @Test
36
42
  fun includeNumbers() {
37
43
  val expectedWordCount = mapOf("testing" to 2, "1" to 1, "2" to 1)
@@ -39,6 +45,7 @@ class WordCountTest {
39
45
  assertEquals(expectedWordCount, WordCount.phrase("testing, 1, 2 testing"))
40
46
  }
41
47
 
48
+ @Ignore
42
49
  @Test
43
50
  fun normalizeCase() {
44
51
  val expectedWordCount = mapOf("go" to 3)
@@ -46,6 +53,7 @@ class WordCountTest {
46
53
  assertEquals(expectedWordCount, WordCount.phrase("go Go GO"))
47
54
  }
48
55
 
56
+ @Ignore
49
57
  @Test
50
58
  fun allowApostrophes() {
51
59
  val expectedWordCount = mapOf("first" to 1, "don't" to 2, "laugh" to 1, "then" to 1, "cry" to 1)
@@ -3,4 +3,4 @@ machine:
3
3
  version: "8.2"
4
4
  test:
5
5
  override:
6
- -echo 'i am working'
6
+ -xctool test -project 'xcodeProject/ObjectiveC.xcodeproj' -scheme 'xobjectivecTest' -sdk macosx10.11 -reporter json-compilation-database:compile_commands.json -reporter plain:plain-output.txt -reporter pretty
@@ -2,8 +2,8 @@
2
2
  sudo: false
3
3
  language: perl6
4
4
  install:
5
- - rakudobrew build-panda
6
- - panda install JSON::Tiny
5
+ - rakudobrew build zef
6
+ - zef install JSON::Tiny
7
7
  before_script:
8
8
  - bin/fetch-configlet
9
9
  script:
@@ -110,6 +110,11 @@
110
110
  "difficulty": 1,
111
111
  "slug": "space-age",
112
112
  "topics": []
113
+ },
114
+ {
115
+ "difficulty": 1,
116
+ "slug": "linked-list",
117
+ "topics": []
113
118
  }
114
119
  ]
115
120
  }
@@ -2,44 +2,104 @@
2
2
 
3
3
  ## Run All Tests
4
4
 
5
- The test (`.t`) files are just Perl 6 scripts, so you can run them directly as any other script:
5
+ There is a Perl 6 script with the extension `.t`, which will be used to test
6
+ your solution. You can run through the tests by using the command:
6
7
 
7
- `perl6 bob.t`
8
+ `prove . --exec=perl6`
8
9
 
9
- This will produce an output like:
10
+ Before you start the exercise, the output will likely look something like:
10
11
 
11
- ````
12
- 1..2
13
- ok 1 - Load module
14
- ok 2 - Class Bob has hey() method
15
- ````
12
+ ```
13
+ ./hello-world.t .. 1/6
14
+ # Failed test 'No argument'
15
+ # at ./hello-world.t line 28
16
+ # expected: 'Hello, World!'
17
+ # got: (Nil)
16
18
 
17
- (this is called the [TAP - Test Anything Protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol) format)
19
+ # Failed test 'Empty string'
20
+ # at ./hello-world.t line 29
21
+ # expected: 'Hello, World!'
22
+ # got: (Nil)
23
+ ./hello-world.t .. Dubious, test returned 2 (wstat 512, 0x200)
24
+ Failed 2/6 subtests
25
+
26
+ Test Summary Report
27
+ -------------------
28
+ ./hello-world.t (Wstat: 512 Tests: 6 Failed: 2)
29
+ Failed tests: 3-4
30
+ Non-zero exit status: 2
31
+ ```
32
+ You will either need to modify or create a module with the extension `.pm6`, and
33
+ write a solution to pass the tests. Once the tests are passing, the output from
34
+ the command above will likely look something like:
35
+
36
+ ```
37
+ ./hello-world.t .. ok
38
+ All tests successful.
39
+ Files=1, Tests=6, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.37 cusr 0.04 csys = 0.44 CPU)
40
+ Result: PASS
41
+ ```
42
+
43
+ Some exercises may have optional tests. You can test for these by adding the
44
+ flag `-v` (for 'verbose') to the above command, like so:
45
+
46
+ `prove . --exec=perl6 -v`
47
+
48
+ The output will likely look something like:
49
+
50
+ ```
51
+ ./hello-world.t ..
52
+ 1..6
53
+ ok 1 - The module can be use-d ok
54
+ 1..1
55
+ ok 1 - &hello
56
+ ok 2 - Subroutine(s)
57
+ ok 3 - No argument
58
+ ok 4 - Empty string
59
+ not ok 5 - Camelia # TODO optional test
60
+
61
+ # Failed test 'Camelia'
62
+ # at ./hello-world.t line 31
63
+ # expected: 'Hello, Camelia!'
64
+ # got: 'Hello, World!'
65
+ not ok 6 - Rakudo # TODO optional test
66
+
67
+ # Failed test 'Rakudo'
68
+ # at ./hello-world.t line 32
69
+ # expected: 'Hello, 楽土!'
70
+ # got: 'Hello, World!'
71
+ ok
72
+ All tests successful.
73
+ Files=1, Tests=6, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.58 cusr 0.06 csys = 0.67 CPU)
74
+ Result: PASS
75
+ ```
18
76
 
19
77
  ## Stop After First Failure
20
78
 
21
- If you have the `PERL6_TEST_DIE_ON_FAIL` environment variable set, the test runner will stop after the first failure. For example:
79
+ If you have the `PERL6_TEST_DIE_ON_FAIL` environment variable set, the test
80
+ runner will stop after the first failure. For example:
22
81
 
23
82
  In Linux / OS X:
24
83
 
25
- ````bash
84
+ ```bash
26
85
  export PERL6_TEST_DIE_ON_FAIL=1
27
86
  # now all the follow up runs will stop at the first failure
28
- perl6 bob.t
87
+ prove . --exec=perl6
29
88
  # until we do
30
89
  unset PERL6_TEST_DIE_ON_FAIL
31
90
  # or you can use it for one run like this:
32
- PERL6_TEST_DIE_ON_FAIL=1 perl6 bob.t
33
- ````
91
+ PERL6_TEST_DIE_ON_FAIL=1 prove . --exec=perl6
92
+ ```
34
93
 
35
94
  Or in Windows:
36
95
 
37
- ````
96
+ ```
38
97
  SET PERL6_TEST_DIE_ON_FAIL=1
39
98
  REM now all the follow up runs will stop at the first failure
40
- perl6 bob.t
99
+ prove . --exec=perl6
41
100
  REM until we do
42
101
  set PERL6_TEST_DIE_ON_FAIL=
43
- ````
102
+ ```
44
103
 
45
- For more information see the [Testing chapter of the Perl 6 Documentation](https://docs.perl6.org/language/testing.html).
104
+ For more information see the
105
+ [Testing chapter of the Perl 6 Documentation](https://docs.perl6.org/language/testing.html).
@@ -5,13 +5,8 @@ use JSON::Tiny;
5
5
 
6
6
  use lib ( my $dir = IO::Path.new($?FILE).parent ).path;
7
7
 
8
- my $module_name = %*ENV<EXERCISM>.so ?? 'Example' !! 'Allergies';
9
- my @potential_module = <p6 pm6 pm>.map: $module_name ~ '.' ~ *;
10
-
11
- my $module = first { $dir.child($_).e }, |@potential_module
12
- or die "No file '$module_name.p6' found\n";
13
-
14
- require $module <&allergic-to &list-allergies>;
8
+ my $module = %*ENV<EXERCISM> ?? 'Example' !! 'Allergies';
9
+ require ::($module) <&allergic-to &list-allergies>;
15
10
 
16
11
  plan 2;
17
12
 
@@ -5,13 +5,8 @@ use JSON::Tiny;
5
5
 
6
6
  use lib ( my $dir = IO::Path.new($?FILE).parent ).path;
7
7
 
8
- my $module_name = %*ENV<EXERCISM>.so ?? 'Example' !! 'Cipher';
9
- my @potential_module = <p6 pm6 pm>.map: $module_name ~ '.' ~ *;
10
-
11
- my $module = first { $dir.child($_).e }, |@potential_module
12
- or die "No file '$module_name.p6' found\n";
13
-
14
- require $module <&encode &decode>;
8
+ my $module = %*ENV<EXERCISM> ?? 'Example' !! 'Cipher';
9
+ require ::($module) <&encode &decode>;
15
10
 
16
11
  plan 2;
17
12
 
@@ -0,0 +1,51 @@
1
+ class ListNode {
2
+ has $.next is rw;
3
+ has $.previous is rw;
4
+ has $.value;
5
+ }
6
+
7
+ class LinkedList is export {
8
+ has $!first;
9
+ has $!last;
10
+
11
+ method push($value) {
12
+ my $next = ListNode.new( value => $value, previous => $!last );
13
+ if ( $!last ) {
14
+ $!last = $!last.next= $next ;
15
+ }
16
+ else {
17
+ $!first = $!last = $next;
18
+ }
19
+ }
20
+
21
+ method unshift($value) {
22
+ my $next = ListNode.new( value => $value, next => $!first );
23
+ if ( $!first ) {
24
+ $!first = $!first.previous = $next ;
25
+ }
26
+ else {
27
+ $!first = $!last = $next;
28
+ }
29
+ }
30
+
31
+ method shift() {
32
+ my $f = $!first;
33
+
34
+ $!first = $!first.next;
35
+
36
+ unless $!first { $!last = $!first }
37
+
38
+ return $f.value;
39
+ }
40
+
41
+ method pop() {
42
+ my $f = $!last;
43
+
44
+ $!last = $!last.previous;
45
+
46
+ unless $!.last { $!first = $!last }
47
+
48
+ return $f.value;
49
+ }
50
+ };
51
+
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env perl6
2
+
3
+ use Test;
4
+ use JSON::Tiny;
5
+
6
+ use lib IO::Path.new($?FILE).parent.path;
7
+
8
+ my $module = %*ENV<EXERCISM> ?? 'Example' !! 'LinkedList';
9
+ require ::($module) <LinkedList>;
10
+
11
+ my @cases; # defined in INIT
12
+
13
+ plan 0 + @cases;
14
+
15
+ for @cases -> $c {
16
+ subtest $c.<name>, sub {
17
+ my $ll = LinkedList.new;
18
+ for |$c.<set> -> %s {
19
+ for %s {
20
+ my $v = $_.value;
21
+ given $_.key {
22
+ when 'push' { $ll.push( $v ); pass 'push ' ~ $v }
23
+ when 'unshift' { $ll.unshift( $v ); pass 'unshift ' ~ $v }
24
+ when 'pop' { is $ll.pop, $v, 'pop' }
25
+ when 'shift' { is $ll.shift, $v, 'shift' }
26
+ }
27
+ }
28
+ }
29
+ };
30
+ }
31
+
32
+
33
+ done-testing;
34
+
35
+ INIT {
36
+ @cases := from-json 「
37
+ [
38
+ {
39
+ "set" : [
40
+ { "push" : 10 },
41
+ { "push" : 20 },
42
+ { "pop" : 20 },
43
+ { "pop" : 10 }
44
+ ],
45
+ "name" : "push_pop"
46
+ },
47
+ {
48
+ "set" : [
49
+ { "push" : 10 },
50
+ { "push" : 20 },
51
+ { "shift" : 10 },
52
+ { "shift" : 20 }
53
+ ],
54
+ "name" : "push_shift"
55
+ },
56
+ {
57
+ "set" : [
58
+ { "unshift" : 10 },
59
+ { "unshift" : 20 },
60
+ { "shift" : 20 },
61
+ { "shift" : 10 }
62
+ ],
63
+ "name" : "unshift_shift"
64
+ },
65
+ {
66
+ "set" : [
67
+ { "unshift" : 10 },
68
+ { "unshift" : 20 },
69
+ { "pop" : 10 },
70
+ { "pop" : 20 }
71
+ ],
72
+ "name" : "unshift_pop"
73
+ },
74
+ {
75
+ "set" : [
76
+ { "push" : 10 },
77
+ { "push" : 20 },
78
+ { "pop" : 20 },
79
+ { "push" : 30 },
80
+ { "shift" : 10 },
81
+ { "unshift" : 40 },
82
+ { "push" : 50 },
83
+ { "shift" : 40 },
84
+ { "pop" : 50 },
85
+ { "shift" : 30 }
86
+ ],
87
+ "name" : "example"
88
+ }
89
+ ]
90
+
91
+ }