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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/common/CONTRIBUTING.md +9 -349
  3. data/common/exercises/forth/canonical-data.json +1 -7
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/bash/config.json +5 -0
  6. data/tracks/bash/exercises/anagram/anagram_tests.sh +99 -0
  7. data/tracks/bash/exercises/anagram/example.sh +23 -0
  8. data/tracks/delphi/config.json +8 -1
  9. data/tracks/delphi/exercises/two-fer/twofer.dpr +60 -0
  10. data/tracks/delphi/exercises/two-fer/utwoferExample.pas +17 -0
  11. data/tracks/delphi/exercises/two-fer/utwoferTest.pas +71 -0
  12. data/tracks/dlang/README.md +9 -5
  13. data/tracks/dlang/bin/test-exercise +14 -5
  14. data/tracks/dlang/docs/INSTALLATION.md +24 -0
  15. data/tracks/dlang/docs/TESTS.md +6 -6
  16. data/tracks/dlang/exercises/bob/dub.sdl +2 -0
  17. data/tracks/dlang/exercises/bob/{bob_example.d → example/bob.d} +0 -5
  18. data/tracks/dlang/exercises/bob/{bob.d → source/bob.d} +0 -5
  19. data/tracks/dlang/exercises/circular-buffer/dub.sdl +2 -0
  20. data/tracks/dlang/exercises/circular-buffer/{circular_buffer_example.d → example/circular_buffer.d} +0 -5
  21. data/tracks/dlang/exercises/circular-buffer/{circular_buffer.d → source/circular_buffer.d} +0 -5
  22. data/tracks/dlang/exercises/crypto-square/dub.sdl +2 -0
  23. data/tracks/dlang/exercises/crypto-square/{crypto_square_example.d → example/crypto_square.d} +0 -5
  24. data/tracks/dlang/exercises/crypto-square/{crypto_square.d → source/crypto_square.d} +0 -5
  25. data/tracks/dlang/exercises/difference-of-squares/dub.sdl +2 -0
  26. data/tracks/dlang/exercises/difference-of-squares/{difference_of_squares_example.d → example/difference_of_squares.d} +0 -2
  27. data/tracks/dlang/exercises/difference-of-squares/{difference_of_squares.d → source/difference_of_squares.d} +0 -2
  28. data/tracks/dlang/exercises/etl/dub.sdl +2 -0
  29. data/tracks/dlang/exercises/etl/{etl_example.d → example/etl.d} +0 -5
  30. data/tracks/dlang/exercises/etl/{etl.d → source/etl.d} +0 -5
  31. data/tracks/dlang/exercises/gigasecond/dub.sdl +2 -0
  32. data/tracks/dlang/exercises/gigasecond/{gigasecond_example.d → example/gigasecond.d} +0 -2
  33. data/tracks/dlang/exercises/gigasecond/{gigasecond.d → source/gigasecond.d} +0 -2
  34. data/tracks/dlang/exercises/hamming/dub.sdl +2 -0
  35. data/tracks/dlang/exercises/hamming/{hamming_example.d → example/hamming.d} +0 -5
  36. data/tracks/dlang/exercises/hamming/{hamming.d → source/hamming.d} +0 -5
  37. data/tracks/dlang/exercises/hello-world/dub.sdl +2 -0
  38. data/tracks/dlang/exercises/hello-world/{hello_world_example.d → example/hello_world.d} +0 -2
  39. data/tracks/dlang/exercises/hello-world/{hello_world.d → source/hello_world.d} +0 -0
  40. data/tracks/dlang/exercises/leap/dub.sdl +2 -0
  41. data/tracks/dlang/exercises/leap/{leap_example.d → example/leap.d} +0 -2
  42. data/tracks/dlang/exercises/leap/{leap.d → source/leap.d} +0 -2
  43. data/tracks/dlang/exercises/nucleotide-count/dub.sdl +2 -0
  44. data/tracks/dlang/exercises/nucleotide-count/{nucleotide_count_example.d → example/nucleotide_count.d} +0 -4
  45. data/tracks/dlang/exercises/nucleotide-count/{nucleotide_count.d → source/nucleotide_count.d} +0 -4
  46. data/tracks/dlang/exercises/pangram/dub.sdl +2 -0
  47. data/tracks/dlang/exercises/pangram/{pangram_example.d → example/pangram.d} +0 -2
  48. data/tracks/dlang/exercises/pangram/{pangram.d → source/pangram.d} +0 -2
  49. data/tracks/dlang/exercises/raindrops/dub.sdl +2 -0
  50. data/tracks/dlang/exercises/raindrops/{raindrops_example.d → example/raindrops.d} +0 -2
  51. data/tracks/dlang/exercises/raindrops/{raindrops.d → source/raindrops.d} +0 -2
  52. data/tracks/dlang/exercises/react/dub.sdl +2 -0
  53. data/tracks/dlang/exercises/react/{react_example.d → example/react.d} +0 -2
  54. data/tracks/dlang/exercises/react/{react.d → source/react.d} +0 -2
  55. data/tracks/dlang/exercises/rna-transcription/dub.sdl +2 -0
  56. data/tracks/dlang/exercises/rna-transcription/{rna_transcription_example.d → example/rna_transcription.d} +0 -2
  57. data/tracks/dlang/exercises/rna-transcription/{rna_transcription.d → source/rna_transcription.d} +0 -2
  58. data/tracks/dlang/exercises/robot-name/dub.sdl +2 -0
  59. data/tracks/dlang/exercises/robot-name/{robot_name_example.d → example/robot_name.d} +0 -5
  60. data/tracks/dlang/exercises/robot-name/{robot_name.d → source/robot_name.d} +0 -4
  61. data/tracks/dlang/exercises/roman-numerals/dub.sdl +2 -0
  62. data/tracks/dlang/exercises/roman-numerals/{roman_numerals_example.d → example/roman_numerals.d} +0 -4
  63. data/tracks/dlang/exercises/roman-numerals/{roman_numerals.d → source/roman_numerals.d} +0 -4
  64. data/tracks/dlang/exercises/series/dub.sdl +2 -0
  65. data/tracks/dlang/exercises/series/{series_example.d → example/series.d} +0 -5
  66. data/tracks/dlang/exercises/series/{series.d → source/series.d} +0 -5
  67. data/tracks/dlang/exercises/triangle/dub.sdl +2 -0
  68. data/tracks/dlang/exercises/triangle/{triangle_example.d → example/triangle.d} +0 -5
  69. data/tracks/dlang/exercises/triangle/{triangle.d → source/triangle.d} +0 -5
  70. data/tracks/elisp/.github/stale.yml +0 -0
  71. data/tracks/elisp/exercises/grains/grains-test.el +12 -12
  72. data/tracks/elisp/exercises/robot-name/robot-name-test.el +8 -19
  73. data/tracks/elisp/exercises/word-count/word-count-test.el +27 -27
  74. data/tracks/fortran/Makefile +3 -2
  75. data/tracks/fortran/config.json +21 -2
  76. data/tracks/fortran/exercises/difference-of-squares/difference_of_squares.fun +42 -0
  77. data/tracks/fortran/exercises/difference-of-squares/example.f90 +35 -0
  78. data/tracks/fortran/exercises/{hello_world → hello-world}/example.f90 +0 -0
  79. data/tracks/fortran/exercises/{hello_world → hello-world}/hello_world.fun +0 -0
  80. data/tracks/fortran/exercises/raindrops/example.f90 +26 -0
  81. data/tracks/fortran/exercises/raindrops/raindrops.fun +78 -0
  82. data/tracks/fortran/exercises/rna-transcription/example.f90 +27 -0
  83. data/tracks/fortran/exercises/rna-transcription/rna_transcription.fun +38 -0
  84. data/tracks/go/exercises/acronym/.meta/gen.go +51 -0
  85. data/tracks/go/exercises/acronym/acronym_test.go +1 -15
  86. data/tracks/go/exercises/acronym/cases_test.go +37 -0
  87. data/tracks/go/exercises/acronym/example.go +1 -1
  88. data/tracks/go/exercises/secret-handshake/.meta/gen.go +49 -0
  89. data/tracks/go/exercises/secret-handshake/cases_test.go +24 -0
  90. data/tracks/go/exercises/secret-handshake/example.go +1 -1
  91. data/tracks/go/exercises/secret-handshake/secret_handshake_test.go +1 -17
  92. data/tracks/java/config.json +23 -23
  93. data/tracks/java/exercises/book-store/src/example/java/{Bookstore.java → BookStore.java} +5 -12
  94. data/tracks/java/exercises/book-store/src/test/java/BookStoreTest.java +113 -0
  95. data/tracks/java/exercises/saddle-points/src/example/java/Matrix.java +5 -4
  96. data/tracks/java/exercises/saddle-points/src/example/java/MatrixCoordinate.java +5 -5
  97. data/tracks/java/exercises/saddle-points/src/main/java/MatrixCoordinate.java +5 -5
  98. data/tracks/java/exercises/saddle-points/src/test/java/MatrixTest.java +10 -10
  99. data/tracks/purescript/config.json +7 -0
  100. data/tracks/purescript/exercises/hamming/bower.json +16 -0
  101. data/tracks/purescript/exercises/hamming/examples/src/Hamming.purs +14 -0
  102. data/tracks/purescript/exercises/hamming/test/Main.purs +46 -0
  103. data/tracks/scala/config.json +7 -0
  104. data/tracks/scala/exercises/bob/example.scala +3 -3
  105. data/tracks/scala/exercises/bob/src/main/scala/Bob.scala +2 -2
  106. data/tracks/scala/exercises/bob/src/test/scala/BobTest.scala +83 -53
  107. data/tracks/scala/exercises/book-store/build.sbt +3 -0
  108. data/tracks/scala/exercises/book-store/example.scala +49 -0
  109. data/tracks/scala/exercises/book-store/src/main/scala/.keep +0 -0
  110. data/tracks/scala/exercises/book-store/src/test/scala/BookStoreTest.scala +70 -0
  111. data/tracks/scala/exercises/difference-of-squares/example.scala +3 -3
  112. data/tracks/scala/exercises/difference-of-squares/src/main/scala/DifferenceOfSquares.scala +8 -0
  113. data/tracks/scala/exercises/difference-of-squares/src/test/scala/DifferenceOfSquaresTest.scala +49 -0
  114. data/tracks/scala/exercises/leap/example.scala +4 -3
  115. data/tracks/scala/exercises/leap/src/main/scala/Leap.scala +2 -2
  116. data/tracks/scala/exercises/leap/src/test/scala/LeapTest.scala +12 -20
  117. data/tracks/scala/exercises/raindrops/src/test/scala/RaindropsTest.scala +46 -35
  118. data/tracks/scala/testgen/src/main/scala/BobTestGenerator.scala +15 -0
  119. data/tracks/scala/testgen/src/main/scala/BookStoreTestGenerator.scala +15 -0
  120. data/tracks/scala/testgen/src/main/scala/DifferenceOfSquaresTestGenerator.scala +17 -0
  121. data/tracks/scala/testgen/src/main/scala/LeapTestGenerator.scala +15 -0
  122. data/tracks/scala/testgen/src/main/scala/RaindropsTestGenerator.scala +15 -0
  123. data/tracks/vimscript/config.json +5 -0
  124. data/tracks/vimscript/exercises/triangle/example.vim +28 -0
  125. data/tracks/vimscript/exercises/triangle/triangle.vader +92 -0
  126. data/tracks/vimscript/exercises/triangle/triangle.vim +24 -0
  127. metadata +93 -44
  128. data/tracks/java/exercises/book-store/src/test/java/BookstoreTest.java +0 -119
  129. data/tracks/scala/exercises/difference-of-squares/src/main/scala/Squares.scala +0 -8
  130. data/tracks/scala/exercises/difference-of-squares/src/test/scala/SquaresTest.scala +0 -56
@@ -0,0 +1,8 @@
1
+ object DifferenceOfSquares {
2
+
3
+ def sumOfSquares(n: Int): Int = ???
4
+
5
+ def squareOfSum(n: Int): Int = ???
6
+
7
+ def differenceOfSquares(n: Int): Int = ???
8
+ }
@@ -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 Year {
2
- def isLeap(year: Int): Boolean = {
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 Year {
2
- def isLeap(year: Int): Boolean = ???
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
- class LeapTest extends FunSuite {
4
- test ("vanilla leap year") {
5
- assert(Year.isLeap(1996))
6
- }
3
+ /** @version 1.0.0 */
4
+ class LeapTest extends FunSuite with Matchers {
7
5
 
8
- test ("any old year") {
9
- pending
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 ("century") {
10
+ test("year divisible by 4, not divisible by 100: leap year") {
19
11
  pending
20
- assert(!Year.isLeap(1900))
12
+ Leap.leapYear(2016) should be (true)
21
13
  }
22
14
 
23
- test ("exceptional century") {
15
+ test("year divisible by 100, not divisible by 400: common year") {
24
16
  pending
25
- assert(Year.isLeap(2000))
17
+ Leap.leapYear(2100) should be (false)
26
18
  }
27
19
 
28
- test("exceptional century that is no millenium") {
20
+ test("year divisible by 400: leap year") {
29
21
  pending
30
- assert(Year.isLeap(1600))
22
+ Leap.leapYear(2000) should be (true)
31
23
  }
32
- }
24
+ }
@@ -1,83 +1,94 @@
1
- import org.scalatest.{Matchers, FlatSpec}
1
+ import org.scalatest.{Matchers, FunSuite}
2
2
 
3
- class RaindropsTest extends FlatSpec with Matchers {
4
- it should "convert 1" in {
5
- Raindrops.convert(1) should equal("1")
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
- it should "convert 3" in {
10
+ test("the sound for 3 is Pling") {
9
11
  pending
10
- Raindrops.convert(3) should equal("Pling")
12
+ Raindrops.convert(3) should be ("Pling")
11
13
  }
12
14
 
13
- it should "convert 5" in {
15
+ test("the sound for 5 is Plang") {
14
16
  pending
15
- Raindrops.convert(5) should equal("Plang")
17
+ Raindrops.convert(5) should be ("Plang")
16
18
  }
17
19
 
18
- it should "convert 7" in {
20
+ test("the sound for 7 is Plong") {
19
21
  pending
20
- Raindrops.convert(7) should equal("Plong")
22
+ Raindrops.convert(7) should be ("Plong")
21
23
  }
22
24
 
23
- it should "convert 6" in {
25
+ test("the sound for 6 is Pling as it has a factor 3") {
24
26
  pending
25
- Raindrops.convert(6) should equal("Pling")
27
+ Raindrops.convert(6) should be ("Pling")
26
28
  }
27
29
 
28
- it should "convert 9" in {
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(9) should equal("Pling")
32
+ Raindrops.convert(8) should be ("8")
31
33
  }
32
34
 
33
- it should "convert 10" in {
35
+ test("the sound for 9 is Pling as it has a factor 3") {
34
36
  pending
35
- Raindrops.convert(10) should equal("Plang")
37
+ Raindrops.convert(9) should be ("Pling")
36
38
  }
37
39
 
38
- it should "convert 14" in {
40
+ test("the sound for 10 is Plang as it has a factor 5") {
39
41
  pending
40
- Raindrops.convert(14) should equal("Plong")
42
+ Raindrops.convert(10) should be ("Plang")
41
43
  }
42
44
 
43
- it should "convert 15" in {
45
+ test("the sound for 14 is Plong as it has a factor of 7") {
44
46
  pending
45
- Raindrops.convert(15) should equal("PlingPlang")
47
+ Raindrops.convert(14) should be ("Plong")
46
48
  }
47
49
 
48
- it should "convert 21" in {
50
+ test("the sound for 15 is PlingPlang as it has factors 3 and 5") {
49
51
  pending
50
- Raindrops.convert(21) should equal("PlingPlong")
52
+ Raindrops.convert(15) should be ("PlingPlang")
51
53
  }
52
54
 
53
- it should "convert 25" in {
55
+ test("the sound for 21 is PlingPlong as it has factors 3 and 7") {
54
56
  pending
55
- Raindrops.convert(25) should equal("Plang")
57
+ Raindrops.convert(21) should be ("PlingPlong")
56
58
  }
57
59
 
58
- it should "convert 35" in {
60
+ test("the sound for 25 is Plang as it has a factor 5") {
59
61
  pending
60
- Raindrops.convert(35) should equal("PlangPlong")
62
+ Raindrops.convert(25) should be ("Plang")
61
63
  }
62
64
 
63
- it should "convert 49" in {
65
+ test("the sound for 27 is Pling as it has a factor 3") {
64
66
  pending
65
- Raindrops.convert(49) should equal("Plong")
67
+ Raindrops.convert(27) should be ("Pling")
66
68
  }
67
69
 
68
- it should "convert 52" in {
70
+ test("the sound for 35 is PlangPlong as it has factors 5 and 7") {
69
71
  pending
70
- Raindrops.convert(52) should equal("52")
72
+ Raindrops.convert(35) should be ("PlangPlong")
71
73
  }
72
74
 
73
- it should "convert 105" in {
75
+ test("the sound for 49 is Plong as it has a factor 7") {
74
76
  pending
75
- Raindrops.convert(105) should equal("PlingPlangPlong")
77
+ Raindrops.convert(49) should be ("Plong")
76
78
  }
77
79
 
78
- it should "convert 12121" in {
80
+ test("the sound for 52 is 52") {
79
81
  pending
80
- Raindrops.convert(12121) should equal("12121")
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
+ }
@@ -80,6 +80,11 @@
80
80
  "slug": "scrabble-score",
81
81
  "difficulty": 1,
82
82
  "topics": []
83
+ },
84
+ {
85
+ "slug": "triangle",
86
+ "difficulty": 1,
87
+ "topics": []
83
88
  }
84
89
  ],
85
90
  "deprecated": [],
@@ -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
+