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
data/tracks/scala/exercises/difference-of-squares/src/test/scala/DifferenceOfSquaresTest.scala
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
import org.scalatest.{Matchers, FunSuite}
|
2
|
+
|
3
|
+
/** @version 1.1.0 */
|
4
|
+
class DifferenceOfSquaresTest extends FunSuite with Matchers {
|
5
|
+
|
6
|
+
test("square of sum 1") {
|
7
|
+
DifferenceOfSquares.squareOfSum(1) should be (1)
|
8
|
+
}
|
9
|
+
|
10
|
+
test("square of sum 5") {
|
11
|
+
pending
|
12
|
+
DifferenceOfSquares.squareOfSum(5) should be (225)
|
13
|
+
}
|
14
|
+
|
15
|
+
test("square of sum 100") {
|
16
|
+
pending
|
17
|
+
DifferenceOfSquares.squareOfSum(100) should be (25502500)
|
18
|
+
}
|
19
|
+
|
20
|
+
test("sum of squares 1") {
|
21
|
+
pending
|
22
|
+
DifferenceOfSquares.sumOfSquares(1) should be (1)
|
23
|
+
}
|
24
|
+
|
25
|
+
test("sum of squares 5") {
|
26
|
+
pending
|
27
|
+
DifferenceOfSquares.sumOfSquares(5) should be (55)
|
28
|
+
}
|
29
|
+
|
30
|
+
test("sum of squares 100") {
|
31
|
+
pending
|
32
|
+
DifferenceOfSquares.sumOfSquares(100) should be (338350)
|
33
|
+
}
|
34
|
+
|
35
|
+
test("difference of squares 1") {
|
36
|
+
pending
|
37
|
+
DifferenceOfSquares.differenceOfSquares(1) should be (0)
|
38
|
+
}
|
39
|
+
|
40
|
+
test("difference of squares 5") {
|
41
|
+
pending
|
42
|
+
DifferenceOfSquares.differenceOfSquares(5) should be (170)
|
43
|
+
}
|
44
|
+
|
45
|
+
test("difference of squares 100") {
|
46
|
+
pending
|
47
|
+
DifferenceOfSquares.differenceOfSquares(100) should be (25164150)
|
48
|
+
}
|
49
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
object
|
2
|
-
def
|
1
|
+
object Leap {
|
2
|
+
def leapYear(year: Int): Boolean = {
|
3
3
|
def divisibleBy(i: Int) = year % i == 0
|
4
|
-
divisibleBy(4) && (divisibleBy(400) || !divisibleBy(100))
|
4
|
+
divisibleBy(4) && (divisibleBy(400) || !divisibleBy(100))
|
5
|
+
}
|
5
6
|
}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
object
|
2
|
-
def
|
1
|
+
object Leap {
|
2
|
+
def leapYear(year: Int): Boolean = ???
|
3
3
|
}
|
@@ -1,32 +1,24 @@
|
|
1
|
-
import org.scalatest.
|
1
|
+
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
assert(Year.isLeap(1996))
|
6
|
-
}
|
3
|
+
/** @version 1.0.0 */
|
4
|
+
class LeapTest extends FunSuite with Matchers {
|
7
5
|
|
8
|
-
test
|
9
|
-
|
10
|
-
assert(!Year.isLeap(1997))
|
11
|
-
}
|
12
|
-
|
13
|
-
test("an even year") {
|
14
|
-
pending
|
15
|
-
assert(!Year.isLeap(1986))
|
6
|
+
test("year not divisible by 4: common year") {
|
7
|
+
Leap.leapYear(2015) should be (false)
|
16
8
|
}
|
17
9
|
|
18
|
-
test
|
10
|
+
test("year divisible by 4, not divisible by 100: leap year") {
|
19
11
|
pending
|
20
|
-
|
12
|
+
Leap.leapYear(2016) should be (true)
|
21
13
|
}
|
22
14
|
|
23
|
-
test
|
15
|
+
test("year divisible by 100, not divisible by 400: common year") {
|
24
16
|
pending
|
25
|
-
|
17
|
+
Leap.leapYear(2100) should be (false)
|
26
18
|
}
|
27
19
|
|
28
|
-
test("
|
20
|
+
test("year divisible by 400: leap year") {
|
29
21
|
pending
|
30
|
-
|
22
|
+
Leap.leapYear(2000) should be (true)
|
31
23
|
}
|
32
|
-
}
|
24
|
+
}
|
@@ -1,83 +1,94 @@
|
|
1
|
-
import org.scalatest.{Matchers,
|
1
|
+
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
/** @version 1.0.0 */
|
4
|
+
class RaindropsTest extends FunSuite with Matchers {
|
5
|
+
|
6
|
+
test("the sound for 1 is 1") {
|
7
|
+
Raindrops.convert(1) should be ("1")
|
6
8
|
}
|
7
9
|
|
8
|
-
|
10
|
+
test("the sound for 3 is Pling") {
|
9
11
|
pending
|
10
|
-
Raindrops.convert(3) should
|
12
|
+
Raindrops.convert(3) should be ("Pling")
|
11
13
|
}
|
12
14
|
|
13
|
-
|
15
|
+
test("the sound for 5 is Plang") {
|
14
16
|
pending
|
15
|
-
Raindrops.convert(5) should
|
17
|
+
Raindrops.convert(5) should be ("Plang")
|
16
18
|
}
|
17
19
|
|
18
|
-
|
20
|
+
test("the sound for 7 is Plong") {
|
19
21
|
pending
|
20
|
-
Raindrops.convert(7) should
|
22
|
+
Raindrops.convert(7) should be ("Plong")
|
21
23
|
}
|
22
24
|
|
23
|
-
it
|
25
|
+
test("the sound for 6 is Pling as it has a factor 3") {
|
24
26
|
pending
|
25
|
-
Raindrops.convert(6) should
|
27
|
+
Raindrops.convert(6) should be ("Pling")
|
26
28
|
}
|
27
29
|
|
28
|
-
|
30
|
+
test("2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base") {
|
29
31
|
pending
|
30
|
-
Raindrops.convert(
|
32
|
+
Raindrops.convert(8) should be ("8")
|
31
33
|
}
|
32
34
|
|
33
|
-
it
|
35
|
+
test("the sound for 9 is Pling as it has a factor 3") {
|
34
36
|
pending
|
35
|
-
Raindrops.convert(
|
37
|
+
Raindrops.convert(9) should be ("Pling")
|
36
38
|
}
|
37
39
|
|
38
|
-
it
|
40
|
+
test("the sound for 10 is Plang as it has a factor 5") {
|
39
41
|
pending
|
40
|
-
Raindrops.convert(
|
42
|
+
Raindrops.convert(10) should be ("Plang")
|
41
43
|
}
|
42
44
|
|
43
|
-
it
|
45
|
+
test("the sound for 14 is Plong as it has a factor of 7") {
|
44
46
|
pending
|
45
|
-
Raindrops.convert(
|
47
|
+
Raindrops.convert(14) should be ("Plong")
|
46
48
|
}
|
47
49
|
|
48
|
-
it
|
50
|
+
test("the sound for 15 is PlingPlang as it has factors 3 and 5") {
|
49
51
|
pending
|
50
|
-
Raindrops.convert(
|
52
|
+
Raindrops.convert(15) should be ("PlingPlang")
|
51
53
|
}
|
52
54
|
|
53
|
-
it
|
55
|
+
test("the sound for 21 is PlingPlong as it has factors 3 and 7") {
|
54
56
|
pending
|
55
|
-
Raindrops.convert(
|
57
|
+
Raindrops.convert(21) should be ("PlingPlong")
|
56
58
|
}
|
57
59
|
|
58
|
-
it
|
60
|
+
test("the sound for 25 is Plang as it has a factor 5") {
|
59
61
|
pending
|
60
|
-
Raindrops.convert(
|
62
|
+
Raindrops.convert(25) should be ("Plang")
|
61
63
|
}
|
62
64
|
|
63
|
-
it
|
65
|
+
test("the sound for 27 is Pling as it has a factor 3") {
|
64
66
|
pending
|
65
|
-
Raindrops.convert(
|
67
|
+
Raindrops.convert(27) should be ("Pling")
|
66
68
|
}
|
67
69
|
|
68
|
-
it
|
70
|
+
test("the sound for 35 is PlangPlong as it has factors 5 and 7") {
|
69
71
|
pending
|
70
|
-
Raindrops.convert(
|
72
|
+
Raindrops.convert(35) should be ("PlangPlong")
|
71
73
|
}
|
72
74
|
|
73
|
-
it
|
75
|
+
test("the sound for 49 is Plong as it has a factor 7") {
|
74
76
|
pending
|
75
|
-
Raindrops.convert(
|
77
|
+
Raindrops.convert(49) should be ("Plong")
|
76
78
|
}
|
77
79
|
|
78
|
-
|
80
|
+
test("the sound for 52 is 52") {
|
79
81
|
pending
|
80
|
-
Raindrops.convert(
|
82
|
+
Raindrops.convert(52) should be ("52")
|
83
|
+
}
|
84
|
+
|
85
|
+
test("the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7") {
|
86
|
+
pending
|
87
|
+
Raindrops.convert(105) should be ("PlingPlangPlong")
|
81
88
|
}
|
82
|
-
}
|
83
89
|
|
90
|
+
test("the sound for 3125 is Plang as it has a factor 5") {
|
91
|
+
pending
|
92
|
+
Raindrops.convert(3125) should be ("Plang")
|
93
|
+
}
|
94
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import java.io.File
|
2
|
+
|
3
|
+
import testgen.TestSuiteBuilder
|
4
|
+
import testgen.TestSuiteBuilder.fromLabeledTest
|
5
|
+
|
6
|
+
object BobTestGenerator {
|
7
|
+
def main(args: Array[String]): Unit = {
|
8
|
+
val file = new File("bob.json")
|
9
|
+
|
10
|
+
val code = TestSuiteBuilder.build(file, fromLabeledTest("input"))
|
11
|
+
println(s"-------------")
|
12
|
+
println(code)
|
13
|
+
println(s"-------------")
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import java.io.File
|
2
|
+
|
3
|
+
import testgen.TestSuiteBuilder
|
4
|
+
import testgen.TestSuiteBuilder.fromLabeledTest
|
5
|
+
|
6
|
+
object BookStoreTestGenerator {
|
7
|
+
def main(args: Array[String]): Unit = {
|
8
|
+
val file = new File("book-store.json")
|
9
|
+
|
10
|
+
val code = TestSuiteBuilder.build(file, fromLabeledTest("basket"))
|
11
|
+
println(s"-------------")
|
12
|
+
println(code)
|
13
|
+
println(s"-------------")
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import java.io.File
|
2
|
+
|
3
|
+
import testgen.TestSuiteBuilder._
|
4
|
+
import testgen._
|
5
|
+
|
6
|
+
object DifferenceOfSquaresTestGenerator {
|
7
|
+
def main(args: Array[String]): Unit = {
|
8
|
+
val file = new File("src/main/resources/difference-of-squares.json")
|
9
|
+
|
10
|
+
val code = TestSuiteBuilder.build(file,
|
11
|
+
fromLabeledTestAlt("squareOfSum" -> Seq("number"), "sumOfSquares" -> Seq("number"),
|
12
|
+
"differenceOfSquares" -> Seq("number")))
|
13
|
+
println(s"-------------")
|
14
|
+
println(code)
|
15
|
+
println(s"-------------")
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import java.io.File
|
2
|
+
|
3
|
+
import testgen.TestSuiteBuilder
|
4
|
+
import testgen.TestSuiteBuilder.fromLabeledTest
|
5
|
+
|
6
|
+
object LeapTestGenerator {
|
7
|
+
def main(args: Array[String]): Unit = {
|
8
|
+
val file = new File("leap.json")
|
9
|
+
|
10
|
+
val code = TestSuiteBuilder.build(file, fromLabeledTest("input"))
|
11
|
+
println(s"-------------")
|
12
|
+
println(code)
|
13
|
+
println(s"-------------")
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import java.io.File
|
2
|
+
|
3
|
+
import testgen.TestSuiteBuilder
|
4
|
+
import testgen.TestSuiteBuilder.fromLabeledTest
|
5
|
+
|
6
|
+
object RaindropsTestGenerator {
|
7
|
+
def main(args: Array[String]): Unit = {
|
8
|
+
val file = new File("src/main/resources/raindrops.json")
|
9
|
+
|
10
|
+
val code = TestSuiteBuilder.build(file, fromLabeledTest("number"))
|
11
|
+
println(s"-------------")
|
12
|
+
println(code)
|
13
|
+
println(s"-------------")
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"
|
2
|
+
" TravisCI's Trusty uses Vim 7.4.52. No uniq() for us.
|
3
|
+
"
|
4
|
+
|
5
|
+
function! Equilateral(triangle) abort
|
6
|
+
let [a, b, c] = a:triangle
|
7
|
+
return s:invalid(a:triangle) ? 0 : a == b && a == c
|
8
|
+
endfunction
|
9
|
+
|
10
|
+
function! Isosceles(triangle) abort
|
11
|
+
let [a, b, c] = a:triangle
|
12
|
+
return s:invalid(a:triangle) ? 0 : a == b || a == c || b == c
|
13
|
+
endfunction
|
14
|
+
|
15
|
+
function! Scalene(triangle) abort
|
16
|
+
let [a, b, c] = a:triangle
|
17
|
+
return s:invalid(a:triangle) ? 0 : a != b && a != c && b != c
|
18
|
+
endfunction
|
19
|
+
|
20
|
+
function! s:invalid(triangle) abort
|
21
|
+
let [a, b, c] = a:triangle
|
22
|
+
|
23
|
+
if a == 0 || b == 0 || c == 0 || a + b < c || a + c < b || b + c < a
|
24
|
+
return 1
|
25
|
+
endif
|
26
|
+
|
27
|
+
return 0
|
28
|
+
endfunction
|
@@ -0,0 +1,92 @@
|
|
1
|
+
"
|
2
|
+
" Version: 1.0.0
|
3
|
+
"
|
4
|
+
|
5
|
+
Before:
|
6
|
+
unlet! input expected
|
7
|
+
|
8
|
+
Execute (true if all sides are equal):
|
9
|
+
let input = [2, 2, 2]
|
10
|
+
let expected = 1
|
11
|
+
AssertEqual expected, Equilateral(input)
|
12
|
+
|
13
|
+
Execute (false if any side is unequal):
|
14
|
+
let input = [2, 3, 2]
|
15
|
+
let expected = 0
|
16
|
+
AssertEqual expected, Equilateral(input)
|
17
|
+
|
18
|
+
Execute (false if no sides are equal):
|
19
|
+
let input = [5, 4, 6]
|
20
|
+
let expected = 0
|
21
|
+
AssertEqual expected, Equilateral(input)
|
22
|
+
|
23
|
+
Execute (All zero sides are illegal, so the triangle is not equilateral):
|
24
|
+
let input = [0, 0, 0]
|
25
|
+
let expected = 0
|
26
|
+
AssertEqual expected, Equilateral(input)
|
27
|
+
|
28
|
+
Execute (sides may be floats):
|
29
|
+
let input = [0.5, 0.5, 0.5]
|
30
|
+
let expected = 1
|
31
|
+
AssertEqual expected, Equilateral(input)
|
32
|
+
|
33
|
+
Execute (true if last two sides are equal):
|
34
|
+
let input = [3, 4, 4]
|
35
|
+
let expected = 1
|
36
|
+
AssertEqual expected, Isosceles(input)
|
37
|
+
|
38
|
+
Execute (true if first two sides are equal):
|
39
|
+
let input = [4, 4, 3]
|
40
|
+
let expected = 1
|
41
|
+
AssertEqual expected, Isosceles(input)
|
42
|
+
|
43
|
+
Execute (true if first and last sides are equal):
|
44
|
+
let input = [4, 3, 4]
|
45
|
+
let expected = 1
|
46
|
+
AssertEqual expected, Isosceles(input)
|
47
|
+
|
48
|
+
Execute (equilateral triangles are also isosceles):
|
49
|
+
let input = [4, 4, 4]
|
50
|
+
let expected = 1
|
51
|
+
AssertEqual expected, Isosceles(input)
|
52
|
+
|
53
|
+
Execute (false if no sides are equal):
|
54
|
+
let input = [2, 3, 4]
|
55
|
+
let expected = 0
|
56
|
+
AssertEqual expected, Isosceles(input)
|
57
|
+
|
58
|
+
Execute (Sides that violate triangle inequality are not isosceles, even if two are equal):
|
59
|
+
let input = [1, 1, 3]
|
60
|
+
let expected = 0
|
61
|
+
AssertEqual expected, Isosceles(input)
|
62
|
+
|
63
|
+
Execute (sides may be floats):
|
64
|
+
let input = [0.5, 0.4, 0.5]
|
65
|
+
let expected = 1
|
66
|
+
AssertEqual expected, Isosceles(input)
|
67
|
+
|
68
|
+
Execute (true if no sides are equal):
|
69
|
+
let input = [5, 4, 6]
|
70
|
+
let expected = 1
|
71
|
+
AssertEqual expected, Scalene(input)
|
72
|
+
|
73
|
+
Execute (false if all sides are equal):
|
74
|
+
let input = [4, 4, 4]
|
75
|
+
let expected = 0
|
76
|
+
AssertEqual expected, Scalene(input)
|
77
|
+
|
78
|
+
Execute (false if two sides are equal):
|
79
|
+
let input = [4, 4, 3]
|
80
|
+
let expected = 0
|
81
|
+
AssertEqual expected, Scalene(input)
|
82
|
+
|
83
|
+
Execute (Sides that violate triangle inequality are not scalene, even if they are all different):
|
84
|
+
let input = [7, 3, 2]
|
85
|
+
let expected = 0
|
86
|
+
AssertEqual expected, Scalene(input)
|
87
|
+
|
88
|
+
Execute (sides may be floats):
|
89
|
+
let input = [0.5, 0.4, 0.6]
|
90
|
+
let expected = 1
|
91
|
+
AssertEqual expected, Scalene(input)
|
92
|
+
|