trackler 2.0.6.17 → 2.0.6.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/exercises/leap/test/test_leap.c +1 -1
- data/tracks/coldfusion/{leap → exercises/leap}/example.cfc +0 -0
- data/tracks/coldfusion/{leap → exercises/leap}/leap.cfc +0 -0
- data/tracks/coldfusion/{leap → exercises/leap}/leap_tests.cfc +0 -0
- data/tracks/cpp/CMakeLists.txt +4 -3
- data/tracks/cpp/{anagram → exercises/anagram}/CMakeLists.txt +0 -0
- data/tracks/cpp/{anagram → exercises/anagram}/anagram_test.cpp +0 -0
- data/tracks/cpp/{anagram → exercises/anagram}/example.cpp +0 -0
- data/tracks/cpp/{anagram → exercises/anagram}/example.h +0 -0
- data/tracks/cpp/{beer-song → exercises/beer-song}/CMakeLists.txt +0 -0
- data/tracks/cpp/{beer-song → exercises/beer-song}/beer_song_test.cpp +0 -0
- data/tracks/cpp/{beer-song → exercises/beer-song}/example.cpp +0 -0
- data/tracks/cpp/{beer-song → exercises/beer-song}/example.h +0 -0
- data/tracks/cpp/{binary → exercises/binary}/CMakeLists.txt +0 -0
- data/tracks/cpp/{binary → exercises/binary}/binary_test.cpp +0 -0
- data/tracks/cpp/{binary → exercises/binary}/example.cpp +0 -0
- data/tracks/cpp/{binary → exercises/binary}/example.h +0 -0
- data/tracks/cpp/{bob → exercises/bob}/CMakeLists.txt +0 -0
- data/tracks/cpp/{bob → exercises/bob}/bob_test.cpp +0 -0
- data/tracks/cpp/{bob → exercises/bob}/example.cpp +0 -0
- data/tracks/cpp/{bob → exercises/bob}/example.h +0 -0
- data/tracks/cpp/{clock → exercises/clock}/CMakeLists.txt +0 -0
- data/tracks/cpp/{clock → exercises/clock}/clock_test.cpp +0 -0
- data/tracks/cpp/{clock → exercises/clock}/example.cpp +0 -0
- data/tracks/cpp/{clock → exercises/clock}/example.h +0 -0
- data/tracks/cpp/{crypto-square → exercises/crypto-square}/CMakeLists.txt +0 -0
- data/tracks/cpp/{crypto-square → exercises/crypto-square}/crypto_square_test.cpp +0 -0
- data/tracks/cpp/{crypto-square → exercises/crypto-square}/example.cpp +0 -0
- data/tracks/cpp/{crypto-square → exercises/crypto-square}/example.h +0 -0
- data/tracks/cpp/{difference-of-squares → exercises/difference-of-squares}/CMakeLists.txt +0 -0
- data/tracks/cpp/{difference-of-squares → exercises/difference-of-squares}/difference_of_squares_test.cpp +0 -0
- data/tracks/cpp/{difference-of-squares → exercises/difference-of-squares}/example.cpp +0 -0
- data/tracks/cpp/{difference-of-squares → exercises/difference-of-squares}/example.h +0 -0
- data/tracks/cpp/{etl → exercises/etl}/CMakeLists.txt +0 -0
- data/tracks/cpp/{etl → exercises/etl}/etl_test.cpp +0 -0
- data/tracks/cpp/{etl → exercises/etl}/example.cpp +0 -0
- data/tracks/cpp/{etl → exercises/etl}/example.h +0 -0
- data/tracks/cpp/{etl → exercises/etl}/require_equal_containers.h +0 -0
- data/tracks/cpp/{food-chain → exercises/food-chain}/CMakeLists.txt +0 -0
- data/tracks/cpp/{food-chain → exercises/food-chain}/example.cpp +0 -0
- data/tracks/cpp/{food-chain → exercises/food-chain}/example.h +0 -0
- data/tracks/cpp/{food-chain → exercises/food-chain}/food_chain_test.cpp +0 -0
- data/tracks/cpp/{gigasecond → exercises/gigasecond}/CMakeLists.txt +0 -0
- data/tracks/cpp/{gigasecond → exercises/gigasecond}/example.cpp +0 -0
- data/tracks/cpp/{gigasecond → exercises/gigasecond}/example.h +0 -0
- data/tracks/cpp/{gigasecond → exercises/gigasecond}/gigasecond_test.cpp +0 -0
- data/tracks/cpp/{grade-school → exercises/grade-school}/CMakeLists.txt +0 -0
- data/tracks/cpp/{grade-school → exercises/grade-school}/example.cpp +0 -0
- data/tracks/cpp/{grade-school → exercises/grade-school}/example.h +0 -0
- data/tracks/cpp/{grade-school → exercises/grade-school}/grade_school_test.cpp +0 -0
- data/tracks/cpp/{grade-school → exercises/grade-school}/require_equal_containers.h +0 -0
- data/tracks/cpp/{grains → exercises/grains}/CMakeLists.txt +0 -0
- data/tracks/cpp/{grains → exercises/grains}/example.cpp +0 -0
- data/tracks/cpp/{grains → exercises/grains}/example.h +0 -0
- data/tracks/cpp/{grains → exercises/grains}/grains_test.cpp +0 -0
- data/tracks/cpp/{hamming → exercises/hamming}/CMakeLists.txt +0 -0
- data/tracks/cpp/{hamming → exercises/hamming}/example.cpp +0 -0
- data/tracks/cpp/{hamming → exercises/hamming}/example.h +0 -0
- data/tracks/cpp/{hamming → exercises/hamming}/hamming_test.cpp +0 -0
- data/tracks/cpp/{hexadecimal → exercises/hexadecimal}/CMakeLists.txt +0 -0
- data/tracks/cpp/{hexadecimal → exercises/hexadecimal}/example.cpp +0 -0
- data/tracks/cpp/{hexadecimal → exercises/hexadecimal}/example.h +0 -0
- data/tracks/cpp/{hexadecimal → exercises/hexadecimal}/hexadecimal_test.cpp +0 -0
- data/tracks/cpp/{leap → exercises/leap}/CMakeLists.txt +0 -0
- data/tracks/cpp/{leap → exercises/leap}/example.h +0 -0
- data/tracks/cpp/{leap → exercises/leap}/leap_test.cpp +0 -0
- data/tracks/cpp/{meetup → exercises/meetup}/CMakeLists.txt +0 -0
- data/tracks/cpp/{meetup → exercises/meetup}/example.h +0 -0
- data/tracks/cpp/{meetup → exercises/meetup}/meetup_test.cpp +0 -0
- data/tracks/cpp/{nth-prime → exercises/nth-prime}/CMakeLists.txt +0 -0
- data/tracks/cpp/{nth-prime → exercises/nth-prime}/example.cpp +0 -0
- data/tracks/cpp/{nth-prime → exercises/nth-prime}/example.h +0 -0
- data/tracks/cpp/{nth-prime → exercises/nth-prime}/nth_prime_test.cpp +0 -0
- data/tracks/cpp/{nucleotide-count → exercises/nucleotide-count}/CMakeLists.txt +0 -0
- data/tracks/cpp/{nucleotide-count → exercises/nucleotide-count}/example.cpp +0 -0
- data/tracks/cpp/{nucleotide-count → exercises/nucleotide-count}/example.h +0 -0
- data/tracks/cpp/{nucleotide-count → exercises/nucleotide-count}/nucleotide_count_test.cpp +0 -0
- data/tracks/cpp/{nucleotide-count → exercises/nucleotide-count}/require_equal_containers.h +0 -0
- data/tracks/cpp/{phone-number → exercises/phone-number}/CMakeLists.txt +0 -0
- data/tracks/cpp/{phone-number → exercises/phone-number}/example.cpp +0 -0
- data/tracks/cpp/{phone-number → exercises/phone-number}/example.h +0 -0
- data/tracks/cpp/{phone-number → exercises/phone-number}/phone_number_test.cpp +0 -0
- data/tracks/cpp/{prime-factors → exercises/prime-factors}/CMakeLists.txt +0 -0
- data/tracks/cpp/{prime-factors → exercises/prime-factors}/example.cpp +0 -0
- data/tracks/cpp/{prime-factors → exercises/prime-factors}/example.h +0 -0
- data/tracks/cpp/{prime-factors → exercises/prime-factors}/prime_factors_test.cpp +0 -0
- data/tracks/cpp/{queen-attack → exercises/queen-attack}/CMakeLists.txt +0 -0
- data/tracks/cpp/{queen-attack → exercises/queen-attack}/example.cpp +0 -0
- data/tracks/cpp/{queen-attack → exercises/queen-attack}/example.h +0 -0
- data/tracks/cpp/{queen-attack → exercises/queen-attack}/queen_attack_test.cpp +0 -0
- data/tracks/cpp/{queen-attack → exercises/queen-attack}/require_equal_containers.h +0 -0
- data/tracks/cpp/{raindrops → exercises/raindrops}/CMakeLists.txt +0 -0
- data/tracks/cpp/{raindrops → exercises/raindrops}/example.cpp +0 -0
- data/tracks/cpp/{raindrops → exercises/raindrops}/example.h +0 -0
- data/tracks/cpp/{raindrops → exercises/raindrops}/raindrops_test.cpp +0 -0
- data/tracks/cpp/{rna-transcription → exercises/rna-transcription}/CMakeLists.txt +0 -0
- data/tracks/cpp/{rna-transcription → exercises/rna-transcription}/example.cpp +0 -0
- data/tracks/cpp/{rna-transcription → exercises/rna-transcription}/example.h +0 -0
- data/tracks/cpp/{rna-transcription → exercises/rna-transcription}/rna_transcription_test.cpp +0 -0
- data/tracks/cpp/{robot-name → exercises/robot-name}/CMakeLists.txt +0 -0
- data/tracks/cpp/{robot-name → exercises/robot-name}/example.cpp +0 -0
- data/tracks/cpp/{robot-name → exercises/robot-name}/example.h +0 -0
- data/tracks/cpp/{robot-name → exercises/robot-name}/robot_name_test.cpp +0 -0
- data/tracks/cpp/{roman-numerals → exercises/roman-numerals}/CMakeLists.txt +0 -0
- data/tracks/cpp/{roman-numerals → exercises/roman-numerals}/example.cpp +0 -0
- data/tracks/cpp/{roman-numerals → exercises/roman-numerals}/example.h +0 -0
- data/tracks/cpp/{roman-numerals → exercises/roman-numerals}/roman_numerals_test.cpp +0 -0
- data/tracks/cpp/{say → exercises/say}/CMakeLists.txt +0 -0
- data/tracks/cpp/{say → exercises/say}/example.cpp +0 -0
- data/tracks/cpp/{say → exercises/say}/example.h +0 -0
- data/tracks/cpp/{say → exercises/say}/say_test.cpp +0 -0
- data/tracks/cpp/{scrabble-score → exercises/scrabble-score}/CMakeLists.txt +0 -0
- data/tracks/cpp/{scrabble-score → exercises/scrabble-score}/example.cpp +0 -0
- data/tracks/cpp/{scrabble-score → exercises/scrabble-score}/example.h +0 -0
- data/tracks/cpp/{scrabble-score → exercises/scrabble-score}/scrabble_score_test.cpp +0 -0
- data/tracks/cpp/{series → exercises/series}/CMakeLists.txt +0 -0
- data/tracks/cpp/{series → exercises/series}/example.cpp +0 -0
- data/tracks/cpp/{series → exercises/series}/example.h +0 -0
- data/tracks/cpp/{series → exercises/series}/require_equal_containers.h +0 -0
- data/tracks/cpp/{series → exercises/series}/series_test.cpp +0 -0
- data/tracks/cpp/{sieve → exercises/sieve}/CMakeLists.txt +0 -0
- data/tracks/cpp/{sieve → exercises/sieve}/example.cpp +0 -0
- data/tracks/cpp/{sieve → exercises/sieve}/example.h +0 -0
- data/tracks/cpp/{sieve → exercises/sieve}/sieve_test.cpp +0 -0
- data/tracks/cpp/{space-age → exercises/space-age}/CMakeLists.txt +0 -0
- data/tracks/cpp/{space-age → exercises/space-age}/example.cpp +0 -0
- data/tracks/cpp/{space-age → exercises/space-age}/example.h +0 -0
- data/tracks/cpp/{space-age → exercises/space-age}/space_age_test.cpp +0 -0
- data/tracks/cpp/{sum-of-multiples → exercises/sum-of-multiples}/CMakeLists.txt +0 -0
- data/tracks/cpp/{sum-of-multiples → exercises/sum-of-multiples}/example.cpp +0 -0
- data/tracks/cpp/{sum-of-multiples → exercises/sum-of-multiples}/example.h +0 -0
- data/tracks/cpp/{sum-of-multiples → exercises/sum-of-multiples}/sum_of_multiples_test.cpp +0 -0
- data/tracks/cpp/{triangle → exercises/triangle}/CMakeLists.txt +0 -0
- data/tracks/cpp/{triangle → exercises/triangle}/example.cpp +0 -0
- data/tracks/cpp/{triangle → exercises/triangle}/example.h +0 -0
- data/tracks/cpp/{triangle → exercises/triangle}/triangle_test.cpp +0 -0
- data/tracks/cpp/{trinary → exercises/trinary}/CMakeLists.txt +0 -0
- data/tracks/cpp/{trinary → exercises/trinary}/example.cpp +0 -0
- data/tracks/cpp/{trinary → exercises/trinary}/example.h +0 -0
- data/tracks/cpp/{trinary → exercises/trinary}/trinary_test.cpp +0 -0
- data/tracks/cpp/{word-count → exercises/word-count}/CMakeLists.txt +0 -0
- data/tracks/cpp/{word-count → exercises/word-count}/example.cpp +0 -0
- data/tracks/cpp/{word-count → exercises/word-count}/example.h +0 -0
- data/tracks/cpp/{word-count → exercises/word-count}/require_equal_containers.h +0 -0
- data/tracks/cpp/{word-count → exercises/word-count}/word_count_test.cpp +0 -0
- data/tracks/csharp/exercises/error-handling/ErrorHandlingTest.cs +3 -3
- data/tracks/fsharp/exercises/linked-list/Example.fs +4 -4
- data/tracks/fsharp/exercises/linked-list/LinkedListTest.fs +35 -19
- data/tracks/groovy/docs/ABOUT.md +5 -10
- data/tracks/groovy/docs/INSTALLATION.md +7 -10
- data/tracks/groovy/docs/LEARNING.md +19 -8
- data/tracks/groovy/docs/RESOURCES.md +9 -23
- data/tracks/groovy/docs/TESTS.md +14 -51
- data/tracks/groovy/exercises/nth-prime/Example.groovy +3 -6
- data/tracks/groovy/exercises/nth-prime/PrimeSpec.groovy +27 -0
- data/tracks/haxe/{bob → exercises/bob}/.munit +0 -0
- data/tracks/haxe/{bob → exercises/bob}/Makefile +0 -0
- data/tracks/haxe/{bob → exercises/bob}/src/example.hx +0 -0
- data/tracks/haxe/{bob → exercises/bob}/test.hxml +0 -0
- data/tracks/haxe/{bob → exercises/bob}/test/BobTest.hx +0 -0
- data/tracks/haxe/{bob → exercises/bob}/test/TestMain.hx +0 -0
- data/tracks/haxe/{bob → exercises/bob}/test/TestSuite.hx +0 -0
- data/tracks/haxe/{hello-world → exercises/hello-world}/.munit +0 -0
- data/tracks/haxe/{hello-world → exercises/hello-world}/Makefile +0 -0
- data/tracks/haxe/{hello-world → exercises/hello-world}/src/example.hx +0 -0
- data/tracks/haxe/{hello-world → exercises/hello-world}/test.hxml +0 -0
- data/tracks/haxe/{hello-world → exercises/hello-world}/test/HelloWorldTest.hx +0 -0
- data/tracks/haxe/{hello-world → exercises/hello-world}/test/TestMain.hx +0 -0
- data/tracks/haxe/{hello-world → exercises/hello-world}/test/TestSuite.hx +0 -0
- data/tracks/java/exercises/luhn/src/example/java/LuhnValidator.java +43 -0
- data/tracks/java/exercises/luhn/src/test/java/LuhnValidatorTest.java +44 -0
- data/tracks/java/exercises/phone-number/src/example/java/PhoneNumber.java +12 -5
- data/tracks/java/exercises/phone-number/src/test/java/PhoneNumberTest.java +10 -12
- data/tracks/julia/config.json +2 -1
- data/tracks/julia/runtests.jl +8 -6
- data/tracks/kotlin/exercises/rna-transcription/src/main/kotlin/RnaTranscription.kt +0 -8
- data/tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt +9 -0
- data/tracks/scala/config.json +3 -0
- data/tracks/scala/exercises/meetup/build.sbt +2 -2
- data/tracks/scala/exercises/meetup/example.scala +22 -33
- data/tracks/scala/exercises/meetup/src/test/scala/MeetupTest.scala +358 -119
- data/tracks/swift/exercises/hello-world/Sources/{deleteme.swift → HelloWorld.swift} +0 -0
- metadata +163 -163
- data/tracks/groovy/exercises/nth-prime/NthPrimeTest.groovy +0 -29
- data/tracks/java/exercises/luhn/src/example/java/Luhn.java +0 -90
- data/tracks/java/exercises/luhn/src/test/java/LuhnTest.java +0 -95
@@ -4,6 +4,14 @@ open NUnit.Framework
|
|
4
4
|
open LinkedList
|
5
5
|
|
6
6
|
[<Test>]
|
7
|
+
let ``Pop returns None if the list is empty`` () =
|
8
|
+
let linkedList = mkLinkedList ()
|
9
|
+
let value = pop linkedList
|
10
|
+
|
11
|
+
Assert.That(value, Is.EqualTo(None))
|
12
|
+
|
13
|
+
[<Test>]
|
14
|
+
[<Ignore("Remove to run test")>]
|
7
15
|
let ``Push and pop are first in last out order`` () =
|
8
16
|
let linkedList = mkLinkedList ()
|
9
17
|
linkedList |> push 10
|
@@ -12,8 +20,16 @@ let ``Push and pop are first in last out order`` () =
|
|
12
20
|
let val1 = pop linkedList
|
13
21
|
let val2 = pop linkedList
|
14
22
|
|
15
|
-
Assert.That(val1, Is.EqualTo(20))
|
16
|
-
Assert.That(val2, Is.EqualTo(10))
|
23
|
+
Assert.That(val1, Is.EqualTo(Some 20))
|
24
|
+
Assert.That(val2, Is.EqualTo(Some 10))
|
25
|
+
|
26
|
+
[<Test>]
|
27
|
+
[<Ignore("Remove to run test")>]
|
28
|
+
let ``Shift returns None if the list is empty`` () =
|
29
|
+
let linkedList = mkLinkedList ()
|
30
|
+
let value = shift linkedList
|
31
|
+
|
32
|
+
Assert.That(value, Is.EqualTo(None))
|
17
33
|
|
18
34
|
[<Test>]
|
19
35
|
[<Ignore("Remove to run test")>]
|
@@ -25,8 +41,8 @@ let ``Push and shift are first in first out order`` () =
|
|
25
41
|
let val1 = shift linkedList
|
26
42
|
let val2 = shift linkedList
|
27
43
|
|
28
|
-
Assert.That(val1, Is.EqualTo(10))
|
29
|
-
Assert.That(val2, Is.EqualTo(20))
|
44
|
+
Assert.That(val1, Is.EqualTo(Some 10))
|
45
|
+
Assert.That(val2, Is.EqualTo(Some 20))
|
30
46
|
|
31
47
|
[<Test>]
|
32
48
|
[<Ignore("Remove to run test")>]
|
@@ -38,8 +54,8 @@ let ``Unshift and shift are last in first out order`` () =
|
|
38
54
|
let val1 = shift linkedList
|
39
55
|
let val2 = shift linkedList
|
40
56
|
|
41
|
-
Assert.That(val1, Is.EqualTo(20))
|
42
|
-
Assert.That(val2, Is.EqualTo(10))
|
57
|
+
Assert.That(val1, Is.EqualTo(Some 20))
|
58
|
+
Assert.That(val2, Is.EqualTo(Some 10))
|
43
59
|
|
44
60
|
[<Test>]
|
45
61
|
[<Ignore("Remove to run test")>]
|
@@ -51,8 +67,8 @@ let ``Unshift and pop are last in last out order`` () =
|
|
51
67
|
let val1 = pop linkedList
|
52
68
|
let val2 = pop linkedList
|
53
69
|
|
54
|
-
Assert.That(val1, Is.EqualTo(10))
|
55
|
-
Assert.That(val2, Is.EqualTo(20))
|
70
|
+
Assert.That(val1, Is.EqualTo(Some 10))
|
71
|
+
Assert.That(val2, Is.EqualTo(Some 20))
|
56
72
|
|
57
73
|
[<Test>]
|
58
74
|
[<Ignore("Remove to run test")>]
|
@@ -66,9 +82,9 @@ let ``Push and pop can handle multiple values`` () =
|
|
66
82
|
let val2 = pop linkedList
|
67
83
|
let val3 = pop linkedList
|
68
84
|
|
69
|
-
Assert.That(val1, Is.EqualTo(30))
|
70
|
-
Assert.That(val2, Is.EqualTo(20))
|
71
|
-
Assert.That(val3, Is.EqualTo(10))
|
85
|
+
Assert.That(val1, Is.EqualTo(Some 30))
|
86
|
+
Assert.That(val2, Is.EqualTo(Some 20))
|
87
|
+
Assert.That(val3, Is.EqualTo(Some 10))
|
72
88
|
|
73
89
|
[<Test>]
|
74
90
|
[<Ignore("Remove to run test")>]
|
@@ -82,9 +98,9 @@ let ``Unshift and shift can handle multiple values`` () =
|
|
82
98
|
let val2 = shift linkedList
|
83
99
|
let val3 = shift linkedList
|
84
100
|
|
85
|
-
Assert.That(val1, Is.EqualTo(30))
|
86
|
-
Assert.That(val2, Is.EqualTo(20))
|
87
|
-
Assert.That(val3, Is.EqualTo(10))
|
101
|
+
Assert.That(val1, Is.EqualTo(Some 30))
|
102
|
+
Assert.That(val2, Is.EqualTo(Some 20))
|
103
|
+
Assert.That(val3, Is.EqualTo(Some 10))
|
88
104
|
|
89
105
|
[<Test>]
|
90
106
|
[<Ignore("Remove to run test")>]
|
@@ -95,12 +111,12 @@ let ``All methods of manipulating the linkedList can be used together`` () =
|
|
95
111
|
|
96
112
|
let val1 = pop linkedList
|
97
113
|
|
98
|
-
Assert.That(val1, Is.EqualTo(20))
|
114
|
+
Assert.That(val1, Is.EqualTo(Some 20))
|
99
115
|
|
100
116
|
linkedList |> push 30
|
101
117
|
let val2 = shift linkedList
|
102
118
|
|
103
|
-
Assert.That(val2, Is.EqualTo(10))
|
119
|
+
Assert.That(val2, Is.EqualTo(Some 10))
|
104
120
|
|
105
121
|
linkedList |> unshift 40
|
106
122
|
linkedList |> push 50
|
@@ -109,6 +125,6 @@ let ``All methods of manipulating the linkedList can be used together`` () =
|
|
109
125
|
let val4 = pop linkedList
|
110
126
|
let val5 = shift linkedList
|
111
127
|
|
112
|
-
Assert.That(val3, Is.EqualTo(40))
|
113
|
-
Assert.That(val4, Is.EqualTo(50))
|
114
|
-
Assert.That(val5, Is.EqualTo(30))
|
128
|
+
Assert.That(val3, Is.EqualTo(Some 40))
|
129
|
+
Assert.That(val4, Is.EqualTo(Some 50))
|
130
|
+
Assert.That(val5, Is.EqualTo(Some 30))
|
data/tracks/groovy/docs/ABOUT.md
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
[Groovy](http://www.groovy-lang.org/)
|
1
|
+
[Groovy](http://www.groovy-lang.org/) is the Apache Foundation's powerful, optionally typed, dynamic language, which also features static-typing and static compilation capabilities.
|
2
2
|
|
3
|
-
Groovy
|
3
|
+
Groovy is aimed at improving developer productivity thanks to a concise, easy to learn syntax. It facilitates scripting, Domain-Specific Language authoring, runtime and compile-time meta-programming, and functional programming.
|
4
4
|
|
5
|
-
|
6
|
-
1. String interpolation, allowing static strings to include references to dynamic variables through the use of GStrings.
|
7
|
-
2. Closures, allowing code to be written a ran at a different time.
|
8
|
-
3. Flexible syntax, with semicolons, dots, and parentheses being optional in many cases.
|
9
|
-
4. Built in XML & JSON parsing.
|
10
|
-
5. [Metaprogramming](https://en.wikipedia.org/wiki/Metaprogramming).
|
5
|
+
It allows access to the entire ecosystem of Java libraries, integrates seamlessly with Java applications.
|
11
6
|
|
12
|
-
|
7
|
+
It can be used as a simple scripting language or added to complicated Java frameworks. It powers technologies like Gradle, Spock, Ratpack, Grails, and scripting in Jenkins.
|
13
8
|
|
14
|
-
|
9
|
+
Also, it is fun.
|
@@ -1,17 +1,14 @@
|
|
1
1
|
### Installation
|
2
2
|
|
3
|
-
#### Installing Java
|
4
|
-
|
5
|
-
In order to work with Groovy, you will also need Java. The instructions for setting up Java can be found on [Oracle](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html), but you may also want to look at the installation instructions found on the [Java Exercism](http://exercism.io/languages/java) page
|
6
|
-
|
7
3
|
#### Installing Groovy
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
#### Install an IDE
|
12
|
-
|
13
|
-
It is recommended to use an IDE for working with your Groovy exercises. It will provide code assistance, automatic compilation, and a GUI for running the tests.
|
5
|
+
The preferred method of installing Groovy is [SDKman](http://sdkman.io/).
|
14
6
|
|
15
|
-
|
7
|
+
Detailed instructions can be found [here](http://sdkman.io/install.html). Breifly, open a shell and issue:
|
16
8
|
|
9
|
+
1. `curl -s "https://get.sdkman.io" | bash`
|
10
|
+
1. `source "~/.sdkman/bin/sdkman-init.sh"`
|
11
|
+
1. `sdk install java`
|
12
|
+
1. `sdk install groovy`
|
17
13
|
|
14
|
+
Other methods of installing Groovy can be found [here](http://groovy-lang.org/install.html).
|
@@ -1,8 +1,19 @@
|
|
1
|
-
Interested in getting started with Groovy, or learning more while you work on exercises?
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
* [
|
6
|
-
*
|
7
|
-
* [
|
8
|
-
|
1
|
+
Interested in getting started with Groovy, or learning more while you work on exercises?
|
2
|
+
|
3
|
+
Try out Groovy
|
4
|
+
|
5
|
+
* [in a browser](https://www.jdoodle.com/execute-groovy-online)
|
6
|
+
* opening the [Groovy Console](http://groovy-lang.org/groovyconsole.html) with `groovyConsole`
|
7
|
+
* opening the [Groovy Shell](http://groovy-lang.org/groovyconsole.html) with `groovysh`
|
8
|
+
|
9
|
+
Take a quick tour of Groovy with
|
10
|
+
|
11
|
+
* Tim Rows' [Groovy Tutorial for Java Developers](https://www.timroes.de/2015/06/27/groovy-tutorial-for-java-developers/) is equally good for non-Java developers
|
12
|
+
* [Learn X in Y minutes, Where X=Groovy ](https://learnxinyminutes.com/docs/groovy/)
|
13
|
+
* SmartThings' [Groovy Basics](http://docs.smartthings.com/en/latest/getting-started/groovy-basics.html)
|
14
|
+
|
15
|
+
Dive deeper with
|
16
|
+
|
17
|
+
* the [Groovy Documentation](http://www.groovy-lang.org/documentation.html)
|
18
|
+
* [Groovy In Action](https://www.manning.com/books/groovy-in-action-second-edition), _The Book_ on Groovy
|
19
|
+
* Ken Kousen's [Making Java Groovy](https://www.manning.com/books/making-java-groovy)
|
@@ -1,30 +1,16 @@
|
|
1
|
-
|
1
|
+
# Recommended Resources
|
2
2
|
|
3
|
-
|
4
|
-
* [Groovy Documentation](http://www.groovy-lang.org/documentation.html)
|
3
|
+
## Documentation
|
5
4
|
|
6
|
-
|
5
|
+
* the official [Groovy Language Documentation](http://docs.groovy-lang.org/docs/latest/html/documentation/)
|
6
|
+
* Apache's [Groovy Documentation](http://www.groovy-lang.org/documentation.html), including the great [Learn Groovy](http://www.groovy-lang.org/learn.html) section
|
7
7
|
|
8
|
-
|
9
|
-
* [Spock](http://spockframework.github.io/spock/docs/1.0/index.html), Groovy based testing framework.
|
8
|
+
# Tools
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
* [
|
14
|
-
* [Spring](https://spring.io/)
|
15
|
-
|
16
|
-
## IDEs
|
17
|
-
|
18
|
-
* [IntelliJ IDEA](https://www.jetbrains.com/idea/)
|
19
|
-
* [Eclipse](https://eclipse.org/), with an additional plugin for Groovy language support.
|
20
|
-
|
21
|
-
## Build Tools
|
22
|
-
|
23
|
-
* [Gradle Docs](http://gradle.org/), an automated build tool, written in Groovy
|
24
|
-
* [Apache Maven](https://maven.apache.org/)
|
25
|
-
* [Gant](https://gant.github.io/)
|
10
|
+
* [SDKman](http://sdkman.io/)
|
11
|
+
* [Groovy Eclipse](https://github.com/groovy/groovy-eclipse/wiki)
|
12
|
+
* [IntelliJ Idea](https://www.jetbrains.com/idea/download/)
|
26
13
|
|
27
14
|
## Collaboration
|
28
15
|
|
29
|
-
* [Groovy Community](http://www.groovy-lang.org/community.html)
|
30
|
-
|
16
|
+
* the [Groovy Community](http://www.groovy-lang.org/community.html) entry of the Groovy Language Documentation
|
data/tracks/groovy/docs/TESTS.md
CHANGED
@@ -1,58 +1,21 @@
|
|
1
|
-
##
|
1
|
+
## Running Tests
|
2
2
|
|
3
|
-
|
3
|
+
Execute the test specification with:
|
4
4
|
|
5
|
+
```bash
|
6
|
+
$ groovy HelloWorldSpec.groovy
|
5
7
|
```
|
6
|
-
C:\Users\You>exercism fetch groovy
|
7
8
|
|
8
|
-
|
9
|
-
groovy (Hello World) Path\To\Your\Exercism\groovy\hello-world
|
9
|
+
## Enabling More Tests
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
Once your code passes all active tests, enable another test by removing the
|
12
|
+
`@Ignore` preceding the next test that interests you. Do this by deleting
|
13
|
+
the `@Ignore` line or comment it out by adding two slashes to the start of
|
14
|
+
the line.
|
13
15
|
|
14
|
-
|
16
|
+
```Groovy
|
17
|
+
//@Ignore
|
18
|
+
def 'outputs "Hello, Alice!" when given the name "Alice"'() {
|
19
|
+
expect: hello.hello('Alice') == 'Hello, Alice!'
|
20
|
+
}
|
15
21
|
```
|
16
|
-
|
17
|
-
## Import the exercise
|
18
|
-
|
19
|
-
1) Start IntelliJ IDEA. In the "Welcome to IntelliJ IDEA" window, click the "Open" option.
|
20
|
-
|
21
|
-
2) Navigate to the "Path\To\Your\Exercism\groovy\THIS_EXERCISE" folder. Make sure you've selected the root directory of the exercise. Click "OK".
|
22
|
-
|
23
|
-
3) Follow the dialog for creating the project from existing external sources.
|
24
|
-
|
25
|
-
4) IntelliJ will then create a new project structure in the editor for your exercise.
|
26
|
-
|
27
|
-
5) Depending on how much of the IDE you have configured before, you will likely need to add a Groovy SDK and a Java SDK (JDK 7+, ideally). These can be configured through the project/module settings by right clicking on the imported project.
|
28
|
-
|
29
|
-
6) You may also need to configure the location of the compiler output (exercism doesn't provide all IDE files since you could work the problems in a myriad of editors instead). This can be configured in the project settings as well.
|
30
|
-
|
31
|
-
## Start the exercise
|
32
|
-
|
33
|
-
1) Open the `README.md` file and carefully read the background for the assignment.
|
34
|
-
|
35
|
-
2) Start by running the test suite: In the "Project" view, right-click on the test file (`hello-world\HelloWorldTest.groovy`), select "Run", then pick the "HelloWorldTest" that has a JUnit icon to the left of it (red and green arrows).
|
36
|
-
|
37
|
-
3) The tests are designed to fail at the beginning. Each exercise will expect you to update the associated groovy file (named the same as the test without the ````Tests```` suffix in the filename.
|
38
|
-
|
39
|
-
4) To skip a test, you can add the @Ignore annotation a test method:
|
40
|
-
|
41
|
-
````
|
42
|
-
//This test will run.
|
43
|
-
@Test
|
44
|
-
void testNoName() {
|
45
|
-
assertTrue new HelloWorld().hello() == 'Hello, World!'
|
46
|
-
}
|
47
|
-
|
48
|
-
//this test will be skipped.
|
49
|
-
@Test
|
50
|
-
@Ignore
|
51
|
-
void testSampleName() {
|
52
|
-
assertTrue new HelloWorld().hello('Alice') == 'Hello, Alice!'
|
53
|
-
}
|
54
|
-
````
|
55
|
-
|
56
|
-
Alternatively, you can simply comment out an entire method to have it removed from compilation and being included in test output.
|
57
|
-
|
58
|
-
5) Update the main Groovy code and re-run the tests until they pass.
|
@@ -1,19 +1,16 @@
|
|
1
|
-
import groovy.transform.CompileStatic
|
2
|
-
|
3
|
-
@CompileStatic
|
4
1
|
class Prime {
|
5
2
|
|
6
|
-
private def isPrime(int n) {
|
3
|
+
private static def isPrime(int n) {
|
7
4
|
def sqrt = Math.ceil(Math.sqrt(n))
|
8
5
|
for (int i = 3; i <= sqrt; i += 1 ) {
|
9
6
|
if ( n % i == 0 ) {
|
10
7
|
return false
|
11
|
-
}
|
8
|
+
}
|
12
9
|
}
|
13
10
|
return true
|
14
11
|
}
|
15
12
|
|
16
|
-
|
13
|
+
static nth(int n) {
|
17
14
|
// handle stuff that doesn't need
|
18
15
|
// additional calculations
|
19
16
|
if ( n < 1 ) throw new ArithmeticException()
|
@@ -0,0 +1,27 @@
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
2
|
+
import spock.lang.*
|
3
|
+
|
4
|
+
class PrimeSpec extends Specification {
|
5
|
+
|
6
|
+
def 'can calculate the first prime'() {
|
7
|
+
expect: Prime.nth(1) == 2
|
8
|
+
}
|
9
|
+
|
10
|
+
def 'can calculate the second prime'() {
|
11
|
+
expect: Prime.nth(2) == 3
|
12
|
+
}
|
13
|
+
|
14
|
+
def 'can calculate the sixth prime'() {
|
15
|
+
expect: Prime.nth(6) == 13
|
16
|
+
}
|
17
|
+
|
18
|
+
def 'can calculate a big prime'() {
|
19
|
+
expect: Prime.nth(10001) == 104743
|
20
|
+
}
|
21
|
+
|
22
|
+
def 'throws exception when asked for the zeroth prime'() {
|
23
|
+
when: Prime.nth(0)
|
24
|
+
then: thrown(ArithmeticException)
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import java.util.ArrayList;
|
2
|
+
import java.util.List;
|
3
|
+
import java.util.regex.Pattern;
|
4
|
+
|
5
|
+
final class LuhnValidator {
|
6
|
+
|
7
|
+
private static final Pattern SPACE_PATTERN = Pattern.compile("\\s+");
|
8
|
+
|
9
|
+
boolean isValid(final String candidate) {
|
10
|
+
final String sanitizedCandidate = SPACE_PATTERN.matcher(candidate).replaceAll("");
|
11
|
+
|
12
|
+
final List<Integer> computedDigits = new ArrayList<>();
|
13
|
+
|
14
|
+
for (int charIndex = 0; charIndex < sanitizedCandidate.length(); charIndex++) {
|
15
|
+
int inputDigit = Character.digit(sanitizedCandidate.charAt(charIndex), 10);
|
16
|
+
|
17
|
+
/*
|
18
|
+
* Character.digit returns a negative int if the supplied character does not represent a digit with respect
|
19
|
+
* to the given radix.
|
20
|
+
*/
|
21
|
+
if (inputDigit < 0) {
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
|
25
|
+
if (charIndex % 2 == 1) {
|
26
|
+
/*
|
27
|
+
* Since our doubled input digit must lie in [2, 18], the operation
|
28
|
+
*
|
29
|
+
* "subtract 9 from the doubled input digit if it exceeds 9 in value"
|
30
|
+
*
|
31
|
+
* is equivalent to applying the modulo operation below universally.
|
32
|
+
*/
|
33
|
+
inputDigit = (2 * inputDigit) % 9;
|
34
|
+
}
|
35
|
+
|
36
|
+
computedDigits.add(inputDigit);
|
37
|
+
}
|
38
|
+
|
39
|
+
final int digitSum = computedDigits.stream().mapToInt(Integer::intValue).sum();
|
40
|
+
return digitSum > 0 && digitSum % 10 == 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import org.junit.Ignore;
|
2
|
+
import org.junit.Test;
|
3
|
+
|
4
|
+
import static org.junit.Assert.assertFalse;
|
5
|
+
import static org.junit.Assert.assertTrue;
|
6
|
+
|
7
|
+
public class LuhnValidatorTest {
|
8
|
+
|
9
|
+
@Test
|
10
|
+
public void testThatSingleDigitStringIsNotValid() {
|
11
|
+
assertFalse(new LuhnValidator().isValid("1"));
|
12
|
+
}
|
13
|
+
|
14
|
+
@Ignore
|
15
|
+
@Test
|
16
|
+
public void testThatTheStringConsistingOfASingleZeroIsInvalid() {
|
17
|
+
assertFalse(new LuhnValidator().isValid("0"));
|
18
|
+
}
|
19
|
+
|
20
|
+
@Ignore
|
21
|
+
@Test
|
22
|
+
public void testThatAValidCanadianSocialInsuranceNumberIsIdentifiedAsValid() {
|
23
|
+
assertTrue(new LuhnValidator().isValid("046 454 286"));
|
24
|
+
}
|
25
|
+
|
26
|
+
@Ignore
|
27
|
+
@Test
|
28
|
+
public void testThatAnInvalidCanadianSocialInsuranceNumberIsIdentifiedAsInvalid() {
|
29
|
+
assertFalse(new LuhnValidator().isValid("046 454 287"));
|
30
|
+
}
|
31
|
+
|
32
|
+
@Ignore
|
33
|
+
@Test
|
34
|
+
public void testThatAnInvalidCreditCardIsIdentifiedAsInvalid() {
|
35
|
+
assertFalse(new LuhnValidator().isValid("8273 1232 7352 0569"));
|
36
|
+
}
|
37
|
+
|
38
|
+
@Ignore
|
39
|
+
@Test
|
40
|
+
public void testThatAddingANonDigitCharacterToAValidStringInvalidatesTheString() {
|
41
|
+
assertFalse(new LuhnValidator().isValid("046a 454 286"));
|
42
|
+
}
|
43
|
+
|
44
|
+
}
|