trackler 2.0.6.10 → 2.0.6.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/circular-buffer/canonical-data.json +343 -0
  3. data/common/exercises/luhn/description.md +4 -1
  4. data/common/exercises/secret-handshake/canonical-data.json +67 -0
  5. data/common/exercises/secret-handshake/description.md +6 -8
  6. data/common/exercises/variable-length-quantity/canonical-data.json +147 -0
  7. data/lib/trackler/version.rb +1 -1
  8. data/tracks/ceylon/.gitignore +1 -0
  9. data/tracks/ceylon/.travis.yml +6 -1
  10. data/tracks/ceylon/README.md +143 -4
  11. data/tracks/ceylon/bin/test-all-exercises +13 -0
  12. data/tracks/ceylon/bin/test-exercise +30 -0
  13. data/tracks/ceylon/config.json +33 -3
  14. data/tracks/ceylon/{SETUP.md → exercises/TRACK_HINTS.md} +0 -0
  15. data/tracks/ceylon/exercises/anagram/example/Anagram.ceylon +8 -0
  16. data/tracks/ceylon/exercises/anagram/source/anagram/Anagram.ceylon +3 -0
  17. data/tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon +47 -0
  18. data/tracks/ceylon/exercises/anagram/source/anagram/module.ceylon +3 -0
  19. data/tracks/ceylon/exercises/bracket-push/example/Brackets.ceylon +18 -0
  20. data/tracks/ceylon/exercises/bracket-push/example/module.ceylon +4 -0
  21. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/Brackets.ceylon +3 -0
  22. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +37 -0
  23. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/module.ceylon +3 -0
  24. data/tracks/ceylon/exercises/leap/example/Leap.ceylon +3 -0
  25. data/tracks/ceylon/exercises/leap/source/leap/Leap.ceylon +3 -0
  26. data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +10 -0
  27. data/tracks/ceylon/exercises/leap/source/leap/module.ceylon +3 -0
  28. data/tracks/ceylon/exercises/sieve/example/Sieve.ceylon +24 -0
  29. data/tracks/ceylon/exercises/sieve/example/module.ceylon +4 -0
  30. data/tracks/ceylon/exercises/sieve/source/sieve/Sieve.ceylon +3 -0
  31. data/tracks/ceylon/exercises/sieve/source/sieve/SieveTest.ceylon +23 -0
  32. data/tracks/ceylon/exercises/sieve/source/sieve/module.ceylon +3 -0
  33. data/tracks/csharp/.travis.yml +4 -0
  34. data/tracks/elm/SETUP.md +5 -4
  35. data/tracks/fsharp/.travis.yml +4 -0
  36. data/tracks/go/config.json +6 -2
  37. data/tracks/go/exercises/luhn/example.go +5 -4
  38. data/tracks/go/exercises/luhn/luhn_test.go +18 -34
  39. data/tracks/java/exercises/word-count/src/test/java/WordCountTest.java +10 -13
  40. data/tracks/lua/docs/ABOUT.md +1 -1
  41. data/tracks/lua/docs/LEARNING.md +1 -0
  42. data/tracks/lua/docs/RESOURCES.md +6 -1
  43. data/tracks/lua/exercises/flatten-array/flatten-array_spec.lua +11 -0
  44. data/tracks/lua/exercises/luhn/example.lua +11 -27
  45. data/tracks/lua/exercises/luhn/luhn_spec.lua +12 -39
  46. data/tracks/ocaml/exercises/all-your-base/all_your_base.mli +0 -2
  47. data/tracks/ocaml/exercises/bracket-push/bracket_push.mli +0 -2
  48. data/tracks/ocaml/exercises/luhn/example.ml +12 -16
  49. data/tracks/ocaml/exercises/luhn/luhn.mli +1 -2
  50. data/tracks/ocaml/exercises/luhn/test.ml +15 -12
  51. data/tracks/php/config.json +8 -0
  52. data/tracks/php/exercises/grains/example.php +63 -0
  53. data/tracks/php/exercises/grains/grains_test.php +82 -0
  54. data/tracks/pony/config.json +26 -14
  55. data/tracks/pony/exercises/anagram/example.pony +17 -73
  56. data/tracks/pony/exercises/anagram/test.pony +6 -13
  57. data/tracks/pony/exercises/bob/example.pony +24 -24
  58. data/tracks/pony/exercises/bob/test.pony +16 -34
  59. data/tracks/pony/exercises/difference-of-squares/example.pony +13 -25
  60. data/tracks/pony/exercises/difference-of-squares/test.pony +9 -16
  61. data/tracks/pony/exercises/hamming/example.pony +8 -23
  62. data/tracks/pony/exercises/hamming/test.pony +16 -30
  63. data/tracks/pony/exercises/hello-world/example.pony +3 -9
  64. data/tracks/pony/exercises/hello-world/test.pony +2 -11
  65. data/tracks/pony/exercises/leap/example.pony +4 -10
  66. data/tracks/pony/exercises/leap/test.pony +2 -11
  67. data/tracks/ruby/lib/generator/command_line.rb +5 -6
  68. data/tracks/ruby/lib/generator/repository.rb +13 -13
  69. data/tracks/ruby/lib/tasks/exercise_test_tasks.rb +2 -4
  70. data/tracks/ruby/lib/tasks/exercise_tests_runner.rb +6 -8
  71. data/tracks/ruby/test/generator/repository_test.rb +26 -34
  72. data/tracks/rust/README.md +1 -1
  73. data/tracks/scheme/config.json +5 -0
  74. data/tracks/scheme/docs/ABOUT.md +7 -0
  75. data/tracks/scheme/exercises/scrabble-score/example.scm +16 -0
  76. data/tracks/scheme/exercises/scrabble-score/scrabble-score-test.scm +57 -0
  77. data/tracks/scheme/exercises/scrabble-score/scrabble-score.scm +2 -0
  78. metadata +33 -5
  79. data/tracks/ceylon/exercises/.keep +0 -0
  80. data/tracks/ceylon/img/.keep +0 -0
@@ -0,0 +1,147 @@
1
+ {
2
+ "#": [
3
+ "JSON doesn't allow hexadecimal literals.",
4
+ "All numbers are given as decimal literals instead.",
5
+ "It is highly recommended that your track's test generator display all numbers as hexadecimal literals."
6
+ ],
7
+ "encode": {
8
+ "description": ["Encode a series of integers, producing a series of bytes."],
9
+ "cases": [
10
+ {
11
+ "description": "zero",
12
+ "input": [0],
13
+ "expected": [0]
14
+ },
15
+ {
16
+ "description": "arbitrary single byte",
17
+ "input": [64],
18
+ "expected": [64]
19
+ },
20
+ {
21
+ "description": "largest single byte",
22
+ "input": [127],
23
+ "expected": [127]
24
+ },
25
+ {
26
+ "description": "smallest double byte",
27
+ "input": [128],
28
+ "expected": [129, 0]
29
+ },
30
+ {
31
+ "description": "arbitrary double byte",
32
+ "input": [8192],
33
+ "expected": [192, 0]
34
+ },
35
+ {
36
+ "description": "largest double byte",
37
+ "input": [16383],
38
+ "expected": [255, 127]
39
+ },
40
+ {
41
+ "description": "smallest triple byte",
42
+ "input": [16384],
43
+ "expected": [129, 128, 0]
44
+ },
45
+ {
46
+ "description": "arbitrary triple byte",
47
+ "input": [1048576],
48
+ "expected": [192, 128, 0]
49
+ },
50
+ {
51
+ "description": "largest triple byte",
52
+ "input": [2097151],
53
+ "expected": [255, 255, 127]
54
+ },
55
+ {
56
+ "description": "smallest quadruple byte",
57
+ "input": [2097152],
58
+ "expected": [129, 128, 128, 0]
59
+ },
60
+ {
61
+ "description": "arbitrary quadruple byte",
62
+ "input": [134217728],
63
+ "expected": [192, 128, 128, 0]
64
+ },
65
+ {
66
+ "description": "largest quadruple byte",
67
+ "input": [268435455],
68
+ "expected": [255, 255, 255, 127]
69
+ },
70
+ {
71
+ "description": "smallest quintuple byte",
72
+ "input": [268435456],
73
+ "expected": [129, 128, 128, 128, 0]
74
+ },
75
+ {
76
+ "description": "arbitrary quintuple byte",
77
+ "input": [4278190080],
78
+ "expected": [143, 248, 128, 128, 0]
79
+ },
80
+ {
81
+ "description": "maximum 32-bit integer input",
82
+ "input": [4294967295],
83
+ "expected": [143, 255, 255, 255, 127]
84
+ },
85
+ {
86
+ "description": "two single-byte values",
87
+ "input": [64, 127],
88
+ "expected": [64, 127]
89
+ },
90
+ {
91
+ "description": "two multi-byte values",
92
+ "input": [16384, 1193046],
93
+ "expected": [129, 128, 0, 200, 232, 86]
94
+ },
95
+ {
96
+ "description": "many multi-byte values",
97
+ "input": [8192, 1193046, 268435455, 0, 16383, 16384],
98
+ "expected": [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0]
99
+ }
100
+ ]
101
+ },
102
+ "decode": {
103
+ "description": ["Decode a series of bytes, producing a series of integers."],
104
+ "cases": [
105
+ {
106
+ "description": "one byte",
107
+ "input": [127],
108
+ "expected": [127]
109
+ },
110
+ {
111
+ "description": "two bytes",
112
+ "input": [192, 0],
113
+ "expected": [8192]
114
+ },
115
+ {
116
+ "description": "three bytes",
117
+ "input": [255, 255, 127],
118
+ "expected": [2097151]
119
+ },
120
+ {
121
+ "description": "four bytes",
122
+ "input": [129, 128, 128, 0],
123
+ "expected": [2097152]
124
+ },
125
+ {
126
+ "description": "maximum 32-bit integer",
127
+ "input": [143, 255, 255, 255, 127],
128
+ "expected": [4294967295]
129
+ },
130
+ {
131
+ "description": "incomplete sequence causes error",
132
+ "input": [255],
133
+ "expected": null
134
+ },
135
+ {
136
+ "description": "incomplete sequence causes error, even if value is zero",
137
+ "input": [128],
138
+ "expected": null
139
+ },
140
+ {
141
+ "description": "multiple values",
142
+ "input": [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0],
143
+ "expected": [8192, 1193046, 268435455, 0, 16383, 16384]
144
+ }
145
+ ]
146
+ }
147
+ }
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.6.10"
2
+ VERSION = "2.0.6.11"
3
3
  end
@@ -2,3 +2,4 @@
2
2
  .DS_Store
3
3
  bin/configlet
4
4
  bin/configlet.exe
5
+ modules/
@@ -1,5 +1,10 @@
1
1
  language: bash
2
2
 
3
- script:
3
+ install:
4
4
  - bin/fetch-configlet
5
+ - curl -s https://get.sdkman.io | bash
6
+ - source $HOME/.sdkman/bin/sdkman-init.sh
7
+ - sdk install ceylon
8
+ script:
5
9
  - bin/configlet .
10
+ - bin/test-all-exercises
@@ -2,13 +2,152 @@
2
2
 
3
3
  Exercism problems in Ceylon.
4
4
 
5
- ## TODO
6
-
7
- _Document how to contribute to the Ceylon track._
5
+ [![Build Status](https://travis-ci.org/exercism/xceylon.svg?branch=master)](https://travis-ci.org/exercism/xceylon)
8
6
 
9
7
  ## Contributing Guide
10
8
 
11
- Please see the [contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data)
9
+ ### Asking for help
10
+
11
+ If you're ever unsure about how to help, don't worry!
12
+ You can just ask in the [Exercism Gitter support](https://gitter.im/exercism/support) channel or by creating an issue [for the Ceylon track](https://github.com/exercism/xceylon/issues/new) and we are happy to help you!
13
+
14
+ ### How to contribute
15
+
16
+ The Exercism-wide [contributing guide](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md) covers topics relevant to contributing to the entire Exercism project, including but not limited to the Ceylon track.
17
+
18
+ * To report a bug or ask a question, [create an issue](https://help.github.com/articles/creating-an-issue/).
19
+ * If you already have a fix for a bug, you could [create a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
20
+
21
+ Depending on what your contribution deals with, you may have to direct it at a certain repository:
22
+
23
+ * If your contribution deals with the README for a problem, it should go to [x-common](https://github.com/exercism/x-common).
24
+ * Otherwise, it probably deals with matters specific to the Ceylon track, in which case it goes to this repository.
25
+ * If you're not sure, you can try here and we will let you know if it should go in x-common.
26
+
27
+ #### Porting an exercise
28
+
29
+ The Exercism site provides a list of [exercises not on the Ceylon track](http://exercism.io/languages/ceylon/todo).
30
+ A possible contribution would be to choose one of these exercises and add it to this track.
31
+ The common contributing guide has a [section on porting an exercise](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#porting-an-exercise-to-another-language-track).
32
+
33
+ Note that you will need to add the problem to the `exercises` section in `config.json` as well, otherwise it will not be available via `exercism fetch` (or any other means, other than by cloning the repository).
34
+
35
+ The order in which the exercises are listed in `config.json` is the order in which they will be served by default by `exercism fetch ceylon`.
36
+
37
+ For the Ceylon track, the files needed to port an exercise are described in the next section about [exercise structure](#exercise-structure).
38
+
39
+ ### Exercise structure
40
+
41
+ Each exercise is located in the `exercises` directory, in a directory with the same name as its slug (the `leap` exercise will be at `exercises/leap`, etc.).
42
+ This directory should contain the following files and directories, where `<slug>` is the slug of the exercise with all hyphens deleted, and `<Slug>` is the CamelCased version:
43
+
44
+ * `source/<slug>/module.ceylon`: the [module descriptor](https://ceylon-lang.org/documentation/tour/modules/#dependencies_and_module_descriptors).
45
+ * This file declares the module and any dependencies.
46
+ * Typically, the only dependency will be on [`ceylon.test`](https://herd.ceylon-lang.org/modules/ceylon.test) at the current Ceylon version.
47
+ * We don't expect to declare any other dependencies in this module descriptor.
48
+ * The student is of course free to add any dependencies here if the student's individual submission requires them.
49
+ * `source/<slug>/<Slug>.ceylon`: the stub solution.
50
+ * This file provides just the type signatures needed to make the tests compile.
51
+ * The implementations for all functions should all be `return nothing;`, which will intentionally fail the tests.
52
+ * `source/<slug>/<Slug>Test.ceylon`: The test file.
53
+ * If there is an `exercises/<slug>/canonical-data.json` in the `x-common` repository, the test cases should typically be those described in that file.
54
+ * If you believe a case should be added or removed, try discussing it in the `x-common` repository to see if it would apply to all tracks.
55
+ * If a modification to the cases only makes sense for the Ceylon track, please note the change in the test file.
56
+ * If no JSON file is present, you may use the same tests as other languages implementing that exercise.
57
+ * Typically, we like to use [parameterized tests](https://ceylon-lang.org/blog/2016/02/22/ceylon-test-new-and-noteworthy/#parameterized_tests) to express the tests with minimal duplication in test code.
58
+ * `example/<Slug>.ceylon`: An example solution that passes the tests.
59
+ * This will not be served to students (all paths containing `example` are not served).
60
+ * Instead, it is used in our [Travis CI run](.travis.yml) to make sure that the exercise is solvable and that the tests make sense.
61
+ * *optional*: `example/module.ceylon`: The module descriptor for the example solution.
62
+ * This is necessary only if the example solution has dependencies other than `ceylon.test`.
63
+ * Wherever possible, the dependencies should be limited to modules under the `ceylon.*` namespace, to avoid burdening Travis CI with having to fetch many external dependencies.
64
+ * We may consider adding external dependencies for an example solution if the exercise would be unnecessarily difficult and/or cumbersome without those particular dependencies.
65
+ * *optional*: `example/*.ceylon`
66
+ * Other files may be included in the `example/` directory if appropriate.
67
+
68
+ As a reminder, the README does not need to be added to this track - it is automatically created using the data in [x-common](https://github.com/exercism/x-common).
69
+ However, if there is any Ceylon-specific information that you would like appended to the README, place this in a `HINTS.md` file in the exercise directory (`exercises/<slug>/HINTS.md`).
70
+
71
+ ### Running the tests
72
+
73
+ As mentioned, [Travis CI](https://travis-ci.org/exercism/xceylon) runs our tests to ensure that our exercises are solvable.
74
+ The tests are run on all pull requests (PRs), and we should strive to only merge PRs for which the tests are passing.
75
+
76
+ It is possible to run these tests locally as well.
77
+ In particular, the [`bin/test-exercise`](bin/test-exercise) will test just one exercise:
78
+
79
+ ```bash
80
+ bin/test-exercise exercises/leap
81
+ ```
82
+
83
+ This script automates the process of moving the example files in, running the tests, and then moving the example files back.
84
+ This is useful when changing an exercise in this repository.
85
+ The test can be run locally to make sure everything is working without having to wait for Travis CI.
86
+
87
+ ### Style and conventions
88
+
89
+ Various choices were made in the past to get the repository to the state it is in now.
90
+ These choices aren't set in stone; they could be changed at a later date.
91
+ But the rationale behind the current choices made will be noted here.
92
+
93
+ #### Style
94
+
95
+ At the time of writing, the current maintainer of the Ceylon track was not able to find any commonly-accepted style guide for Ceylon.
96
+ Nor did the maintainer find automatic linter or formatter.
97
+ Thus, the maintainer was forced to just figure one out and try to be consistent.
98
+ For example, all indents are two spaces because that's the default in the maintainer's editor.
99
+
100
+ The maintainer is not intent on any particular style as long as all the code in the repository is consistent.
101
+ If in the future there happened to be a widely-accepted style guide and/or an automatic formatter, the maintainer would not be opposed to reformatting all code in this repository to comply.
102
+
103
+ #### Idiomatic Ceylon
104
+
105
+ All example code should be idiomatic Ceylon, to set a good example for anyone who might look at this repository for solutions to the exercises.
106
+ The current maintainer may have trouble with this point, since the current maintainer is only a Ceylon beginner and may not be familiar enough with the language to tell what is idiomatic or not.
107
+ Help in this area is especially appreciated.
108
+
109
+ #### Project structure
110
+
111
+ The current maintainer finds it regrettable that the exercise slug must be repeated so many times: `exercises/<slug>/source/<slug>/<Slug>.ceylon`.
112
+
113
+ * `exercises/<slug>` is required by Exercism, otherwise the exercise cannot be served.
114
+ * `source/<slug>` is because the exercise files are placed in a module with the same name as the exercise slug.
115
+ * It doesn't seem possible to run [`ceylon test`](https://ceylon-lang.org/documentation/reference/tool/ceylon/subcommands/ceylon-test.html) without a module, since that is one of the arguments it requires.
116
+ * They could all be named `main` or something similarly nondescript, but perhaps that would get confusing.
117
+ * `<Slug>.ceylon` is not required for any particular reason.
118
+ * Then again, what else would it be named?
119
+ * Again, `Main.ceylon` seems a bit too confusion-prone.
120
+
121
+ The current maintainer wishes there was less duplication, but does not really see a good way out.
122
+ Any ideas here are welcome.
123
+
124
+ #### Stubs
125
+
126
+ We provide the stubs with signatures included because we felt it was not a sufficiently interesting learning experience to make students have to puzzle out the expected signatures by just looking at the tests.
127
+
128
+ Because Ceylon is a statically-typed language, the entire test suite must type-check before it can be run at all.
129
+ Thus, not providing the type signatures forces the students to figure out the types for all the functions being tested, rather than being able to focus on just one at a time.
130
+
131
+ The Ceylon track is not the only track that had to make this decision.
132
+ [Other tracks have discussed this as well](https://github.com/exercism/discussions/issues/114), and come to various conclusions.
133
+
134
+ If students suggest that they would like to have the challenge of figuring out type signatures, we would gladly change our minds on this point.
135
+ They might suggest this on the exercism.io site, or on this repository via issues.
136
+ It's likely that the latter is more often monitored.
137
+
138
+ #### Parameterized tests versus one test at a time
139
+
140
+ As mentioned above, we used parameterized tests since this avoids test code duplication.
141
+
142
+ Unfortunately, since by default all cases are enabled, this runs counter to the usual Exercism style in which only a *single test case* is enabled, and the student enables one more test case after making the previous one pass, taking an iterative process.
143
+
144
+ The [ignore annotation](https://modules.ceylon-lang.org/repo/1/ceylon/test/1.3.1/module-doc/api/index.html#ignore) does not seem like it can be applied to individual cases of a parameterized test.
145
+
146
+ One possible solution to this would be to comment out all cases except the first.
147
+ If this solution were taken, students would need to be aware of this, and be informed that they need to uncomment the cases.
148
+ The Travis CI run would need to uncomment the cases as well (without uncommenting any actual comments, which would probably cause syntax errors!).
149
+
150
+ The current maintainer does not have a good solution to this, so ideas here are welcome.
12
151
 
13
152
  ## License
14
153
 
@@ -0,0 +1,13 @@
1
+ #!/bin/sh
2
+
3
+ test_one=$(dirname $0)/test-exercise
4
+ exercises=$(dirname $(dirname $0))/exercises
5
+ status=0
6
+
7
+ for d in $exercises/*/; do
8
+ if ! $test_one $d; then
9
+ status=1
10
+ fi
11
+ done
12
+
13
+ exit $status
@@ -0,0 +1,30 @@
1
+ #!/bin/sh
2
+
3
+ if [ $# -eq 0 ]; then
4
+ echo "usage: $0 exercise-slug"
5
+ exit 1
6
+ fi
7
+
8
+ dir=$1
9
+ exercise=$(basename $dir)
10
+ module=$(echo $exercise | tr -d -)
11
+ sourcedir="source/$module"
12
+ backupext=testbak
13
+
14
+ cd $dir
15
+
16
+ for f in example/*; do
17
+ target="$sourcedir/$(basename $f)"
18
+ cp $target $target.$backupext
19
+ cp $f $target
20
+ done
21
+
22
+ ceylon test --compile=force $module
23
+ status=$?
24
+
25
+ for f in example/*; do
26
+ target="$sourcedir/$(basename $f)"
27
+ mv $target.$backupext $target
28
+ done
29
+
30
+ exit $status
@@ -3,9 +3,39 @@
3
3
  "language": "Ceylon",
4
4
  "repository": "https://github.com/exercism/xceylon",
5
5
  "active": false,
6
- "test_pattern": "TODO",
7
- "problems": [
8
-
6
+ "exercises": [
7
+ {
8
+ "slug": "leap",
9
+ "difficulty": 1,
10
+ "topics": [
11
+ "Integers"
12
+ ]
13
+ },
14
+ {
15
+ "slug": "sieve",
16
+ "difficulty": 3,
17
+ "topics": [
18
+ "Filtering",
19
+ "Mathematics"
20
+ ]
21
+ },
22
+ {
23
+ "slug": "anagram",
24
+ "difficulty": 4,
25
+ "topics": [
26
+ "Strings",
27
+ "Filtering"
28
+ ]
29
+ },
30
+ {
31
+ "slug": "bracket-push",
32
+ "difficulty": 6,
33
+ "topics": [
34
+ "Parsing",
35
+ "Stacks",
36
+ "Strings"
37
+ ]
38
+ }
9
39
  ],
10
40
  "deprecated": [
11
41
 
@@ -0,0 +1,8 @@
1
+ {String*} anagrams(String subject, {String*} candidates) {
2
+ value lower = subject.lowercased;
3
+ value chars = sort(lower);
4
+ return candidates.filter((c) {
5
+ value lowerCandidate = c.lowercased;
6
+ return lower != lowerCandidate && chars == sort(lowerCandidate);
7
+ });
8
+ }
@@ -0,0 +1,3 @@
1
+ {String*} anagrams(String subject, {String*} candidates) {
2
+ return nothing;
3
+ }
@@ -0,0 +1,47 @@
1
+ import ceylon.test { ... }
2
+
3
+ {[String, {String*}, {String*}]*} cases =>
4
+ {
5
+ // no matches
6
+ ["diaper", {"hello", "world", "zombies", "pants"}, {}],
7
+ // detects simple anagram
8
+ ["ant", {"tan", "stand", "at"}, {"tan"}],
9
+ // does not detect false positives
10
+ ["galea", {"eagle"}, {}],
11
+ // detects multiple anagrams
12
+ ["master", {"stream", "pigeon", "maters"}, {"stream", "maters"}],
13
+ // does not detect anagram subsets
14
+ ["good", {"dog", "goody"}, {}],
15
+ // detects anagram
16
+ ["listen", {"enlists", "google", "inlets", "banana"}, {"inlets"}],
17
+ // detects multiple anagrams
18
+ [
19
+ "allergy",
20
+ {"gallery", "ballerina", "regally", "clergy", "largely", "leading"},
21
+ {"gallery", "regally", "largely"}
22
+ ],
23
+ // does not detect identical words
24
+ ["corn", {"corn", "dark", "Corn", "rank", "CORN", "cron", "park"}, {"cron"}],
25
+ // does not detect non-anagrams with identical checksum
26
+ ["mass", {"last"}, {}],
27
+ // detects anagrams case-insensitively
28
+ ["Orchestra", {"cashregister", "Carthorse", "radishes"}, {"Carthorse"}],
29
+ // detects anagrams using case-insensitive subject
30
+ ["Orchestra", {"cashregister", "carthorse", "radishes"}, {"carthorse"}],
31
+ // detects anagrams using case-insensitive possible matches
32
+ ["orchestra", {"cashregister", "Carthorse", "radishes"}, {"Carthorse"}],
33
+ // does not detect a word as its own anagram
34
+ ["banana", {"Banana"}, {}],
35
+ // does not detect a anagram if the original word is repeated
36
+ ["go", {"go Go GO"}, {}],
37
+ // anagrams must use all letters exactly once
38
+ ["tapper", {"patter"}, {}],
39
+ // capital word is not own anagram
40
+ ["BANANA", {"Banana"}, {}]
41
+ };
42
+
43
+ test
44
+ parameters(`value cases`)
45
+ void testAnagram(String subject, {String*} candidates, {String*} expected) {
46
+ assertEquals(sort(anagrams(subject, candidates)), sort(expected));
47
+ }