trackler 2.2.1.74 → 2.2.1.75
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fixtures/tracks/fruit/docs/something.md +0 -0
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/README.md +8 -4
- data/problem-specifications/exercises/acronym/canonical-data.json +19 -7
- data/problem-specifications/exercises/all-your-base/canonical-data.json +106 -64
- data/problem-specifications/exercises/allergies/canonical-data.json +37 -13
- data/tracks/c/config.json +176 -176
- data/tracks/clojure/config.json +17 -1
- data/tracks/clojure/exercises/isbn-verifier/README.md +43 -0
- data/tracks/clojure/exercises/isbn-verifier/project.clj +4 -0
- data/tracks/clojure/exercises/isbn-verifier/src/example.clj +17 -0
- data/tracks/clojure/exercises/isbn-verifier/src/isbn_verifier.clj +3 -0
- data/tracks/clojure/exercises/isbn-verifier/test/isbn_verifier_test.clj +42 -0
- data/tracks/clojure/exercises/proverb/README.md +15 -0
- data/tracks/clojure/exercises/proverb/project.clj +4 -0
- data/tracks/clojure/exercises/proverb/src/example.clj +15 -0
- data/tracks/clojure/exercises/proverb/src/proverb.clj +3 -0
- data/tracks/clojure/exercises/proverb/test/proverb_test.clj +14 -0
- data/tracks/common-lisp/docs/LEARNING.md +4 -3
- data/tracks/common-lisp/docs/RESOURCES.md +11 -0
- data/tracks/delphi/.gitignore +1 -0
- data/tracks/delphi/config.json +24 -0
- data/tracks/delphi/docs/INSTALLATION.md +1 -1
- data/tracks/delphi/exercises/isbn-verifier/ISBNVerifier.dpr +60 -0
- data/tracks/delphi/exercises/isbn-verifier/README.md +68 -0
- data/tracks/delphi/exercises/isbn-verifier/uISBNVerifierExample.pas +46 -0
- data/tracks/delphi/exercises/isbn-verifier/uTestISBNVerifier.pas +136 -0
- data/tracks/delphi/exercises/secret-handshake/README.md +56 -0
- data/tracks/delphi/exercises/secret-handshake/SecretHandshake.dpr +60 -0
- data/tracks/delphi/exercises/secret-handshake/uSecretHandshakeExample.pas +56 -0
- data/tracks/delphi/exercises/secret-handshake/uTestSecretHandshake.pas +215 -0
- data/tracks/ecmascript/docs/ABOUT.md +13 -9
- data/tracks/factor/exercises/two-fer/README.md +1 -1
- data/tracks/fsharp/docs/RESOURCES.md +1 -1
- data/tracks/fsharp/generators/{Input.fs → CanonicalData.fs} +5 -10
- data/tracks/fsharp/generators/Exercise.fs +11 -10
- data/tracks/fsharp/generators/{Output.fs → Formatting.fs} +2 -56
- data/tracks/fsharp/generators/Generators.fs +93 -93
- data/tracks/fsharp/generators/Generators.fsproj +9 -4
- data/tracks/fsharp/generators/Options.fs +1 -1
- data/tracks/fsharp/generators/Program.fs +3 -3
- data/tracks/fsharp/generators/Rendering.fs +57 -0
- data/tracks/go/exercises/all-your-base/.meta/gen.go +80 -0
- data/tracks/go/exercises/all-your-base/.meta/hints.md +13 -0
- data/tracks/go/exercises/all-your-base/README.md +16 -1
- data/tracks/go/exercises/all-your-base/all_your_base_test.go +12 -163
- data/tracks/go/exercises/all-your-base/cases_test.go +183 -0
- data/tracks/go/exercises/all-your-base/example.go +25 -29
- data/tracks/java/CONTRIBUTING.md +1 -1
- data/tracks/java/POLICIES.md +15 -1
- data/tracks/java/exercises/flatten-array/.meta/hints.md +58 -0
- data/tracks/java/exercises/flatten-array/README.md +62 -0
- data/tracks/java/exercises/hamming/src/main/java/Hamming.java +1 -1
- data/tracks/java/exercises/matrix/.meta/src/reference/java/Matrix.java +6 -6
- data/tracks/java/exercises/meetup/.meta/src/reference/java/Meetup.java +2 -2
- data/tracks/java/exercises/meetup/.meta/src/reference/java/MeetupSchedule.java +1 -1
- data/tracks/java/exercises/meetup/src/main/java/MeetupSchedule.java +1 -1
- data/tracks/java/exercises/pig-latin/.meta/hints.md +58 -0
- data/tracks/java/exercises/pig-latin/README.md +61 -0
- data/tracks/java/exercises/reverse-string/src/main/java/ReverseString.java +2 -2
- data/tracks/java/exercises/secret-handshake/README.md +1 -1
- data/tracks/javascript/.eslintignore +0 -3
- data/tracks/javascript/exercises/food-chain/example.js +50 -37
- data/tracks/javascript/exercises/octal/example.js +1 -1
- data/tracks/javascript/exercises/robot-name/robot-name.spec.js +7 -7
- data/tracks/javascript/package-lock.json +1846 -0
- data/tracks/python/docs/EXERCISE_README_INSERT.md +15 -0
- data/tracks/python/exercises/accumulate/README.md +15 -0
- data/tracks/python/exercises/acronym/README.md +15 -0
- data/tracks/python/exercises/all-your-base/README.md +15 -0
- data/tracks/python/exercises/all-your-base/all_your_base_test.py +19 -9
- data/tracks/python/exercises/allergies/README.md +15 -0
- data/tracks/python/exercises/alphametics/README.md +15 -0
- data/tracks/python/exercises/anagram/README.md +15 -0
- data/tracks/python/exercises/atbash-cipher/README.md +15 -0
- data/tracks/python/exercises/beer-song/README.md +16 -1
- data/tracks/python/exercises/binary-search-tree/README.md +16 -2
- data/tracks/python/exercises/binary-search/README.md +15 -0
- data/tracks/python/exercises/binary-search/binary_search_test.py +14 -4
- data/tracks/python/exercises/binary/README.md +15 -0
- data/tracks/python/exercises/binary/binary_test.py +14 -4
- data/tracks/python/exercises/bob/README.md +15 -0
- data/tracks/python/exercises/book-store/README.md +15 -0
- data/tracks/python/exercises/bracket-push/README.md +15 -0
- data/tracks/python/exercises/change/README.md +15 -0
- data/tracks/python/exercises/circular-buffer/README.md +15 -0
- data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +15 -5
- data/tracks/python/exercises/circular-buffer/example.py +2 -2
- data/tracks/python/exercises/clock/README.md +15 -0
- data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +1 -1
- data/tracks/python/exercises/collatz-conjecture/README.md +15 -0
- data/tracks/python/exercises/complex-numbers/README.md +15 -0
- data/tracks/python/exercises/connect/README.md +18 -3
- data/tracks/python/exercises/crypto-square/README.md +15 -0
- data/tracks/python/exercises/diamond/README.md +15 -0
- data/tracks/python/exercises/difference-of-squares/README.md +15 -0
- data/tracks/python/exercises/diffie-hellman/README.md +14 -0
- data/tracks/python/exercises/dominoes/README.md +16 -1
- data/tracks/python/exercises/error-handling/README.md +17 -0
- data/tracks/python/exercises/error-handling/error_handling_test.py +13 -3
- data/tracks/python/exercises/error-handling/example.py +1 -1
- data/tracks/python/exercises/etl/README.md +16 -1
- data/tracks/python/exercises/flatten-array/README.md +15 -0
- data/tracks/python/exercises/food-chain/README.md +15 -0
- data/tracks/python/exercises/forth/README.md +15 -0
- data/tracks/python/exercises/forth/example.py +7 -9
- data/tracks/python/exercises/forth/forth_test.py +107 -17
- data/tracks/python/exercises/gigasecond/README.md +15 -0
- data/tracks/python/exercises/go-counting/README.md +21 -3
- data/tracks/python/exercises/grade-school/README.md +15 -0
- data/tracks/python/exercises/grains/README.md +15 -0
- data/tracks/python/exercises/grains/grains_test.py +16 -6
- data/tracks/python/exercises/grep/README.md +15 -0
- data/tracks/python/exercises/hamming/README.md +15 -0
- data/tracks/python/exercises/hamming/hamming_test.py +12 -2
- data/tracks/python/exercises/hello-world/README.md +15 -0
- data/tracks/python/exercises/hexadecimal/README.md +15 -0
- data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +11 -1
- data/tracks/python/exercises/house/README.md +16 -1
- data/tracks/python/exercises/isogram/README.md +15 -0
- data/tracks/python/exercises/kindergarten-garden/README.md +18 -3
- data/tracks/python/exercises/largest-series-product/README.md +15 -0
- data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +14 -4
- data/tracks/python/exercises/leap/README.md +15 -0
- data/tracks/python/exercises/linked-list/README.md +15 -0
- data/tracks/python/exercises/list-ops/README.md +15 -0
- data/tracks/python/exercises/luhn/README.md +15 -0
- data/tracks/python/exercises/markdown/README.md +18 -0
- data/tracks/python/exercises/matrix/README.md +15 -0
- data/tracks/python/exercises/meetup/README.md +31 -12
- data/tracks/python/exercises/meetup/meetup_test.py +11 -1
- data/tracks/python/exercises/minesweeper/README.md +15 -0
- data/tracks/python/exercises/minesweeper/minesweeper_test.py +12 -2
- data/tracks/python/exercises/nth-prime/README.md +15 -0
- data/tracks/python/exercises/nth-prime/nth_prime_test.py +11 -1
- data/tracks/python/exercises/nucleotide-count/README.md +17 -2
- data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +11 -1
- data/tracks/python/exercises/ocr-numbers/README.md +16 -1
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +12 -2
- data/tracks/python/exercises/octal/README.md +15 -0
- data/tracks/python/exercises/octal/octal_test.py +16 -3
- data/tracks/python/exercises/palindrome-products/README.md +16 -1
- data/tracks/python/exercises/pangram/README.md +15 -0
- data/tracks/python/exercises/pascals-triangle/README.md +16 -1
- data/tracks/python/exercises/perfect-numbers/README.md +15 -0
- data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +13 -3
- data/tracks/python/exercises/phone-number/README.md +16 -2
- data/tracks/python/exercises/phone-number/example.py +1 -1
- data/tracks/python/exercises/phone-number/phone_number_test.py +17 -7
- data/tracks/python/exercises/pig-latin/README.md +15 -0
- data/tracks/python/exercises/point-mutations/README.md +15 -0
- data/tracks/python/exercises/poker/README.md +15 -0
- data/tracks/python/exercises/pov/README.md +20 -2
- data/tracks/python/exercises/pov/example.py +2 -2
- data/tracks/python/exercises/pov/pov_test.py +15 -5
- data/tracks/python/exercises/prime-factors/README.md +15 -0
- data/tracks/python/exercises/protein-translation/README.md +15 -0
- data/tracks/python/exercises/protein-translation/protein_translation_test.py +10 -0
- data/tracks/python/exercises/proverb/README.md +14 -0
- data/tracks/python/exercises/pythagorean-triplet/README.md +15 -0
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +11 -1
- data/tracks/python/exercises/queen-attack/README.md +15 -0
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +17 -7
- data/tracks/python/exercises/rail-fence-cipher/README.md +15 -0
- data/tracks/python/exercises/raindrops/README.md +15 -0
- data/tracks/python/exercises/react/README.md +15 -1
- data/tracks/python/exercises/rectangles/README.md +24 -9
- data/tracks/python/exercises/rna-transcription/.meta/hints.md +1 -0
- data/tracks/python/exercises/rna-transcription/README.md +18 -5
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +13 -3
- data/tracks/python/exercises/robot-name/README.md +15 -0
- data/tracks/python/exercises/robot-simulator/README.md +15 -0
- data/tracks/python/exercises/roman-numerals/README.md +15 -0
- data/tracks/python/exercises/rotational-cipher/README.md +15 -0
- data/tracks/python/exercises/run-length-encoding/README.md +15 -0
- data/tracks/python/exercises/saddle-points/README.md +15 -0
- data/tracks/python/exercises/saddle-points/saddle_points_test.py +11 -1
- data/tracks/python/exercises/say/README.md +15 -0
- data/tracks/python/exercises/say/say_test.py +12 -2
- data/tracks/python/exercises/scale-generator/README.md +15 -0
- data/tracks/python/exercises/scale-generator/example.py +3 -3
- data/tracks/python/exercises/scale-generator/scale_generator_test.py +11 -1
- data/tracks/python/exercises/scrabble-score/README.md +15 -0
- data/tracks/python/exercises/secret-handshake/README.md +16 -1
- data/tracks/python/exercises/series/README.md +15 -0
- data/tracks/python/exercises/series/series_test.py +12 -2
- data/tracks/python/exercises/sieve/README.md +15 -0
- data/tracks/python/exercises/simple-cipher/.meta/hints.md +6 -6
- data/tracks/python/exercises/simple-cipher/README.md +17 -1
- data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +12 -2
- data/tracks/python/exercises/simple-linked-list/{hints.md → .meta/hints.md} +10 -10
- data/tracks/python/exercises/simple-linked-list/README.md +16 -0
- data/tracks/python/exercises/simple-linked-list/example.py +2 -2
- data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +13 -3
- data/tracks/python/exercises/space-age/README.md +15 -0
- data/tracks/python/exercises/strain/README.md +16 -3
- data/tracks/python/exercises/sublist/README.md +15 -0
- data/tracks/python/exercises/sum-of-multiples/README.md +18 -3
- data/tracks/python/exercises/tournament/README.md +15 -0
- data/tracks/python/exercises/transpose/README.md +15 -0
- data/tracks/python/exercises/tree-building/README.md +30 -0
- data/tracks/python/exercises/tree-building/example.py +3 -5
- data/tracks/python/exercises/tree-building/tree_building_test.py +16 -6
- data/tracks/python/exercises/triangle/README.md +15 -0
- data/tracks/python/exercises/triangle/example.py +1 -1
- data/tracks/python/exercises/triangle/triangle_test.py +15 -5
- data/tracks/python/exercises/trinary/README.md +15 -0
- data/tracks/python/exercises/twelve-days/README.md +15 -0
- data/tracks/python/exercises/two-bucket/README.md +22 -7
- data/tracks/python/exercises/two-fer/README.md +16 -0
- data/tracks/python/exercises/variable-length-quantity/README.md +15 -0
- data/tracks/python/exercises/variable-length-quantity/variable_length_quantity_test.py +12 -2
- data/tracks/python/exercises/word-count/README.md +15 -0
- data/tracks/python/exercises/word-search/README.md +15 -0
- data/tracks/python/exercises/wordy/README.md +15 -0
- data/tracks/python/exercises/wordy/wordy_test.py +14 -4
- data/tracks/python/exercises/zebra-puzzle/README.md +15 -0
- data/tracks/python/exercises/zipper/README.md +16 -3
- data/tracks/rust/config.json +11 -0
- data/tracks/rust/exercises/saddle-points/.gitignore +8 -0
- data/tracks/rust/exercises/saddle-points/Cargo.toml +5 -0
- data/tracks/rust/exercises/saddle-points/README.md +66 -0
- data/tracks/rust/exercises/saddle-points/example.rs +24 -0
- data/tracks/rust/exercises/saddle-points/src/lib.rs +3 -0
- data/tracks/rust/exercises/saddle-points/tests/saddle-points.rs +60 -0
- metadata +38 -5
@@ -1,12 +1,16 @@
|
|
1
|
-
ECMAScript
|
1
|
+
ECMAScript is the standard that defines JavaScript, the language that allows web pages to be dynamic.
|
2
|
+
It executes in modern web browsers, and can also be executed on servers where the NodeJS platform is installed.
|
3
|
+
JavaScript/ECMAScript is an interpreted language, which means that it doesn't need to be compiled.
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
"ECMAScript has grown to be one of the world’s most widely used general purpose programming languages.
|
6
|
+
It is best known as the language embedded in web browsers but has also been widely adopted for server and embedded applications."
|
7
|
+
—[ECMA International Language Specification](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-ecmascript-overview)
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
_This track is intended for experimenting with the newest features of the JavaScript language and the ECMAScript standard. Here, you will find code that not all browsers are able to run. For widely supported JavaScript, you may be interested in the [JavaScript track](http://exercism.io/languages/javascript)._
|
9
|
+
Starting with the 6th edition (commonly known as ES2015 or ES6) in 2015, a new edition of the standard will be released each year.
|
10
|
+
ES2015 was a major update which brought many enhancements over ES5, including notably template strings, expressive arrow function syntax, and cleaner syntax for defining classes.
|
11
|
+
Support in current browsers is incomplete, and often requires transpilation with a tool like [Babel](https://babeljs.io/).
|
12
12
|
|
13
|
+
_This track supports the latest ECMAScript syntax via Babel and the [babel-preset-env](https://babeljs.io/docs/plugins/preset-env/) plugin.
|
14
|
+
New and experimental features will be enabled with each release of the specification.
|
15
|
+
Here, you will find code that not all browsers are able to run.
|
16
|
+
For widely supported JavaScript based on the ES5 standard, you may be interested in the [JavaScript track](http://exercism.io/languages/javascript)._
|
@@ -43,7 +43,7 @@ readable as we can.
|
|
43
43
|
|
44
44
|
## Testing Exercises
|
45
45
|
|
46
|
-
If you followed the [installation instructions](http://exercism.io/languages/factor/
|
46
|
+
If you followed the [installation instructions](http://exercism.io/languages/factor/installation), just run the provided test suite against your implementation with `"exercise-name" test`.
|
47
47
|
|
48
48
|
## Submitting Exercises
|
49
49
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
### Social media
|
8
8
|
* [StackOverflow ](http://stackoverflow.com/questions/tagged/f%23) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.
|
9
|
-
* The [F# channel](https://functionalprogramming.slack.com/messages/fsharp/) of the [functionalprogramming slack account](https://functionalprogramming.slack.com/). To join, go to [fpchat.com](
|
9
|
+
* The [F# channel](https://functionalprogramming.slack.com/messages/fsharp/) of the [functionalprogramming slack account](https://functionalprogramming.slack.com/). To join, go to [fpchat-invite.herokuapp.com](https://fpchat-invite.herokuapp.com/).
|
10
10
|
* The [F# slack account](https://fsharp.slack.com). To join, you have to [become a member of the F# foundation](http://fsharp.org/guides/slack/).
|
11
11
|
* [/r/fsharp](https://www.reddit.com/r/fsharp) is the F# subreddit.
|
12
12
|
* The [Gitter channel](https://gitter.im/exercism/xfsharp) can be used to ask questions and get support for any issues related to the F# track.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Generators.
|
1
|
+
module Generators.CanonicalData
|
2
2
|
|
3
3
|
open System
|
4
4
|
open System.IO
|
@@ -7,8 +7,6 @@ open Serilog
|
|
7
7
|
open LibGit2Sharp
|
8
8
|
open Newtonsoft.Json
|
9
9
|
open Newtonsoft.Json.Linq
|
10
|
-
open Newtonsoft.Json.Serialization
|
11
|
-
open Humanizer
|
12
10
|
open Options
|
13
11
|
|
14
12
|
let [<Literal>] private ProblemSpecificationsGitUrl = "https://github.com/exercism/problem-specifications.git";
|
@@ -49,9 +47,6 @@ let private readCanonicalData options exercise =
|
|
49
47
|
let exerciseCanonicalDataPath = Path.Combine(options.CanonicalDataDirectory, "exercises", exercise, "canonical-data.json")
|
50
48
|
File.ReadAllText(exerciseCanonicalDataPath)
|
51
49
|
|
52
|
-
let jsonSerializerSettings = JsonSerializerSettings()
|
53
|
-
let jsonSerializer = JsonSerializer()
|
54
|
-
|
55
50
|
type CanonicalDataConverter() =
|
56
51
|
inherit JsonConverter()
|
57
52
|
|
@@ -83,15 +78,15 @@ type CanonicalDataConverter() =
|
|
83
78
|
Version = jToken.["version"].Value<string>()
|
84
79
|
Cases = createCanonicalDataCasesFromJToken jToken }
|
85
80
|
|
86
|
-
override
|
81
|
+
override __.WriteJson(_: JsonWriter, _: obj, _: JsonSerializer) = failwith "Not supported"
|
87
82
|
|
88
|
-
override
|
83
|
+
override __.ReadJson(reader: JsonReader, _: Type, _: obj, _: JsonSerializer) =
|
89
84
|
let jToken = JToken.ReadFrom(reader)
|
90
85
|
createCanonicalDataFromJToken jToken :> obj
|
91
86
|
|
92
|
-
override
|
87
|
+
override __.CanConvert(objectType: Type) = objectType = typeof<CanonicalData>
|
93
88
|
|
94
|
-
let convertCanonicalData canonicalDataContents =
|
89
|
+
let private convertCanonicalData canonicalDataContents =
|
95
90
|
JsonConvert.DeserializeObject<CanonicalData>(canonicalDataContents, CanonicalDataConverter())
|
96
91
|
|
97
92
|
let parseCanonicalData options =
|
@@ -6,7 +6,8 @@ open System.Reflection
|
|
6
6
|
open Newtonsoft.Json.Linq
|
7
7
|
open Humanizer
|
8
8
|
open Serilog
|
9
|
-
open
|
9
|
+
open Formatting
|
10
|
+
open Rendering
|
10
11
|
|
11
12
|
[<AbstractClass>]
|
12
13
|
type Exercise() =
|
@@ -86,7 +87,7 @@ type Exercise() =
|
|
86
87
|
properties
|
87
88
|
|> Map.map (fun key value -> this.MapCanonicalDataCaseProperty (canonicalDataCase, key, value))
|
88
89
|
|
89
|
-
default
|
90
|
+
default __.MapCanonicalDataCaseProperty (_, _, value) = value
|
90
91
|
|
91
92
|
// Convert canonical data to representation used when rendering
|
92
93
|
|
@@ -144,7 +145,7 @@ type Exercise() =
|
|
144
145
|
|
145
146
|
// Generic value/identifier rendering methods
|
146
147
|
|
147
|
-
default
|
148
|
+
default __.RenderValue (_, _, value) = formatValue value
|
148
149
|
|
149
150
|
default this.RenderValueOrIdentifier (canonicalDataCase, key, value) =
|
150
151
|
let properties = this.PropertiesWithIdentifier canonicalDataCase
|
@@ -163,7 +164,7 @@ type Exercise() =
|
|
163
164
|
let value = this.RenderValueWithoutIdentifier (canonicalDataCase, key, value)
|
164
165
|
sprintf "let %s = %s" identifier value
|
165
166
|
|
166
|
-
default
|
167
|
+
default __.RenderIdentifier (_, key, _) = String.camelize key
|
167
168
|
|
168
169
|
default this.RenderIdentifierWithTypeAnnotation (canonicalDataCase, key, value) =
|
169
170
|
let identifier = this.RenderIdentifier (canonicalDataCase, key, value)
|
@@ -212,12 +213,12 @@ type Exercise() =
|
|
212
213
|
default this.RenderSutParameter (canonicalDataCase, key, value) =
|
213
214
|
this.RenderValueOrIdentifier (canonicalDataCase, key, value)
|
214
215
|
|
215
|
-
default
|
216
|
+
default __.RenderSutProperty canonicalDataCase = string canonicalDataCase.Property
|
216
217
|
|
217
218
|
default this.Properties canonicalDataCase =
|
218
219
|
List.append (this.PropertiesUsedAsSutParameter canonicalDataCase) ["expected"]
|
219
220
|
|
220
|
-
default
|
221
|
+
default __.PropertiesUsedAsSutParameter canonicalDataCase =
|
221
222
|
canonicalDataCase.Properties
|
222
223
|
|> Map.toList
|
223
224
|
|> List.map fst
|
@@ -225,13 +226,13 @@ type Exercise() =
|
|
225
226
|
|
226
227
|
// Utility methods to customize rendered output
|
227
228
|
|
228
|
-
default
|
229
|
+
default __.PropertiesWithIdentifier _ = []
|
229
230
|
|
230
|
-
default
|
231
|
+
default __.IdentifierTypeAnnotation (_, _, _) = None
|
231
232
|
|
232
|
-
default
|
233
|
+
default __.UseFullMethodName _ = false
|
233
234
|
|
234
|
-
default
|
235
|
+
default __.AdditionalNamespaces = []
|
235
236
|
|
236
237
|
let createExercises filteredExercise =
|
237
238
|
|
@@ -1,14 +1,9 @@
|
|
1
|
-
module Generators.
|
1
|
+
module Generators.Formatting
|
2
2
|
|
3
3
|
open System
|
4
4
|
open System.Collections.Generic
|
5
|
-
open System.IO
|
6
|
-
open System.Reflection
|
7
5
|
open FSharp.Reflection
|
8
|
-
open DotLiquid
|
9
|
-
open DotLiquid.FileSystems
|
10
6
|
open Newtonsoft.Json.Linq
|
11
|
-
open Input
|
12
7
|
|
13
8
|
let indent level value =
|
14
9
|
let indentation = String.replicate level " "
|
@@ -177,53 +172,4 @@ let formatMultiLineString strings =
|
|
177
172
|
|
178
173
|
strings
|
179
174
|
|> Seq.mapi formatLine
|
180
|
-
|> Seq.toList
|
181
|
-
|
182
|
-
type OutputFilter() =
|
183
|
-
static member Format (input: string) = formatValue input
|
184
|
-
|
185
|
-
static member Indent (input: string) = indent 1 input
|
186
|
-
|
187
|
-
let private fileSystem = EmbeddedFileSystem(Assembly.GetExecutingAssembly(), "")
|
188
|
-
Template.RegisterFilter(OutputFilter().GetType())
|
189
|
-
Template.FileSystem <- fileSystem :> DotLiquid.FileSystems.IFileSystem
|
190
|
-
|
191
|
-
let private registrations = Dictionary<_,_>()
|
192
|
-
let rec private registerTypeTree templateDataType =
|
193
|
-
if registrations.ContainsKey templateDataType then ()
|
194
|
-
elif FSharpType.IsRecord templateDataType then
|
195
|
-
let properties = templateDataType.GetProperties(BindingFlags.Instance ||| BindingFlags.Public)
|
196
|
-
Template.RegisterSafeType(templateDataType, [| for p in properties -> p.Name |])
|
197
|
-
registrations.[templateDataType] <- true
|
198
|
-
for p in properties do registerTypeTree p.PropertyType
|
199
|
-
elif templateDataType.IsGenericType then
|
200
|
-
let t = templateDataType.GetGenericTypeDefinition()
|
201
|
-
if t = typedefof<seq<_>> || t = typedefof<list<_>> then
|
202
|
-
registrations.[templateDataType] <- true
|
203
|
-
registerTypeTree (templateDataType.GetGenericArguments().[0])
|
204
|
-
elif t = typedefof<IDictionary<_,_>> || t = typedefof<Map<_,_>> then
|
205
|
-
registrations.[templateDataType] <- true
|
206
|
-
registerTypeTree (templateDataType.GetGenericArguments().[0])
|
207
|
-
registerTypeTree (templateDataType.GetGenericArguments().[1])
|
208
|
-
elif t = typedefof<option<_>> then
|
209
|
-
Template.RegisterSafeType(templateDataType, [|"Value"; "IsSome"; "IsNone";|])
|
210
|
-
registrations.[templateDataType] <- true
|
211
|
-
registerTypeTree (templateDataType.GetGenericArguments().[0])
|
212
|
-
elif templateDataType.IsArray then
|
213
|
-
registrations.[templateDataType] <- true
|
214
|
-
registerTypeTree (templateDataType.GetElementType())
|
215
|
-
else
|
216
|
-
let properties = templateDataType.GetProperties(BindingFlags.Instance ||| BindingFlags.Public)
|
217
|
-
Template.RegisterSafeType(templateDataType, [| for p in properties -> p.Name |])
|
218
|
-
registrations.[templateDataType] <- true
|
219
|
-
for p in properties do registerTypeTree p.PropertyType
|
220
|
-
|
221
|
-
let renderInlineTemplate template data =
|
222
|
-
data.GetType() |> registerTypeTree
|
223
|
-
|
224
|
-
let parsedTemplate = Template.Parse template
|
225
|
-
parsedTemplate.Render(Hash.FromAnonymousObject(data))
|
226
|
-
|
227
|
-
let renderPartialTemplate templateName data =
|
228
|
-
let template = sprintf "{%% include \"%s\" %%}" templateName
|
229
|
-
renderInlineTemplate template data
|
175
|
+
|> Seq.toList
|
@@ -3,7 +3,7 @@ module Generators.Generators
|
|
3
3
|
open System
|
4
4
|
open System.Globalization
|
5
5
|
open Newtonsoft.Json.Linq
|
6
|
-
open
|
6
|
+
open Formatting
|
7
7
|
open Exercise
|
8
8
|
|
9
9
|
type Acronym() =
|
@@ -15,7 +15,7 @@ type AtbashCipher() =
|
|
15
15
|
type AllYourBase() =
|
16
16
|
inherit Exercise()
|
17
17
|
|
18
|
-
override
|
18
|
+
override __.RenderExpected (_, _, value) =
|
19
19
|
value
|
20
20
|
|> Option.ofNonError
|
21
21
|
|> formatValue
|
@@ -45,7 +45,7 @@ type Allergies() =
|
|
45
45
|
else
|
46
46
|
base.RenderTestMethodBody canonicalDataCase
|
47
47
|
|
48
|
-
override
|
48
|
+
override __.RenderExpected (canonicalDataCase, key, value) =
|
49
49
|
if (canonicalDataCase.Property = "list") then
|
50
50
|
canonicalDataCase.Expected :?> JArray
|
51
51
|
|> Seq.map toAllergen
|
@@ -53,7 +53,7 @@ type Allergies() =
|
|
53
53
|
else
|
54
54
|
base.RenderExpected (canonicalDataCase, key, value)
|
55
55
|
|
56
|
-
override
|
56
|
+
override __.RenderInput (canonicalDataCase, key, value) =
|
57
57
|
match key with
|
58
58
|
| "substance" -> string value
|
59
59
|
| _ -> base.RenderInput (canonicalDataCase, key, value)
|
@@ -61,7 +61,7 @@ type Allergies() =
|
|
61
61
|
type Alphametics() =
|
62
62
|
inherit Exercise()
|
63
63
|
|
64
|
-
member
|
64
|
+
member __.formatMap<'TKey, 'TValue> (value: obj) =
|
65
65
|
if isNull value then
|
66
66
|
"None"
|
67
67
|
else
|
@@ -77,30 +77,30 @@ type Alphametics() =
|
|
77
77
|
else
|
78
78
|
sprintf "%s |> Map.ofList |> Some" formattedList
|
79
79
|
|
80
|
-
override this.RenderExpected (
|
80
|
+
override this.RenderExpected (_, _, value) = this.formatMap<char, int> value
|
81
81
|
|
82
82
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
83
83
|
|
84
84
|
type Anagram() =
|
85
85
|
inherit Exercise()
|
86
86
|
|
87
|
-
override
|
87
|
+
override __.PropertiesWithIdentifier _ = ["candidates"]
|
88
88
|
|
89
89
|
type ArmstrongNumbers() =
|
90
90
|
inherit Exercise()
|
91
91
|
|
92
|
-
override
|
92
|
+
override __.RenderInput (_, _, value) =
|
93
93
|
(value :?> JToken).Value("number")
|
94
94
|
|> formatValue
|
95
95
|
|
96
96
|
type BeerSong() =
|
97
97
|
inherit Exercise()
|
98
98
|
|
99
|
-
override
|
99
|
+
override __.PropertiesUsedAsSutParameter _ = ["startBottles"; "takeDown"]
|
100
100
|
|
101
|
-
override
|
101
|
+
override __.PropertiesWithIdentifier _ = ["expected"]
|
102
102
|
|
103
|
-
override
|
103
|
+
override __.RenderExpected (_, key, value) =
|
104
104
|
(value :?> JArray)
|
105
105
|
|> normalizeJArray
|
106
106
|
|> Seq.map formatValue
|
@@ -109,9 +109,9 @@ type BeerSong() =
|
|
109
109
|
type BinarySearch() =
|
110
110
|
inherit Exercise()
|
111
111
|
|
112
|
-
override
|
112
|
+
override __.PropertiesWithIdentifier _ = ["array"; "value"; "expected"]
|
113
113
|
|
114
|
-
override
|
114
|
+
override __.RenderValueWithoutIdentifier (canonicalDataCase, key, value) =
|
115
115
|
match key with
|
116
116
|
| "array" ->
|
117
117
|
(value :?> JToken).ToObject<string []>() |> formatArray
|
@@ -130,9 +130,9 @@ type BookStore() =
|
|
130
130
|
|
131
131
|
let formatFloat (value:obj) = value :?> float |> sprintf "%.2f"
|
132
132
|
|
133
|
-
override
|
133
|
+
override __.RenderExpected (_, _, value) = formatFloat value
|
134
134
|
|
135
|
-
override
|
135
|
+
override __.PropertiesUsedAsSutParameter canonicalDataCase =
|
136
136
|
base.PropertiesUsedAsSutParameter canonicalDataCase |> List.except ["targetgrouping"]
|
137
137
|
|
138
138
|
type BracketPush() =
|
@@ -141,13 +141,13 @@ type BracketPush() =
|
|
141
141
|
type Change() =
|
142
142
|
inherit Exercise()
|
143
143
|
|
144
|
-
override
|
144
|
+
override __.RenderExpected (_, _, value) =
|
145
145
|
let convertToOption = if value :? JArray then Option.ofObj else Option.ofNonNegativeInt
|
146
146
|
value |> convertToOption |> formatValue
|
147
147
|
|
148
148
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
149
149
|
|
150
|
-
override
|
150
|
+
override __.IdentifierTypeAnnotation (canonicalDataCase, key, _) =
|
151
151
|
match key with
|
152
152
|
| "expected" ->
|
153
153
|
match canonicalDataCase.Properties.["target"] :?> int64 with
|
@@ -167,9 +167,9 @@ type Clock() =
|
|
167
167
|
member private this.renderPropertyValue canonicalDataCase property =
|
168
168
|
this.RenderSutParameter (canonicalDataCase, property, Map.find property canonicalDataCase.Properties)
|
169
169
|
|
170
|
-
override
|
170
|
+
override __.PropertiesWithIdentifier _ = ["clock1"; "clock2"]
|
171
171
|
|
172
|
-
override
|
172
|
+
override __.RenderValueWithIdentifier (canonicalDataCase, key, value) =
|
173
173
|
match key with
|
174
174
|
| "clock1" | "clock2" -> createClock value key
|
175
175
|
| _ -> base.RenderValueWithIdentifier (canonicalDataCase, key, value)
|
@@ -198,13 +198,13 @@ type Clock() =
|
|
198
198
|
type Connect() =
|
199
199
|
inherit Exercise()
|
200
200
|
|
201
|
-
override
|
201
|
+
override __.RenderExpected (_, _, value) =
|
202
202
|
match string value with
|
203
203
|
| "O" -> "(Some White)"
|
204
204
|
| "X" -> "(Some Black)"
|
205
205
|
| _ -> "None"
|
206
206
|
|
207
|
-
override
|
207
|
+
override __.RenderInput (_, _, value) =
|
208
208
|
let lines = (value :?> JArray).ToObject<string seq>() |> List.ofSeq
|
209
209
|
let padSize = List.last lines |> String.length
|
210
210
|
|
@@ -217,7 +217,7 @@ type Connect() =
|
|
217
217
|
type CollatzConjecture() =
|
218
218
|
inherit Exercise()
|
219
219
|
|
220
|
-
override
|
220
|
+
override __.RenderExpected (_, _, value) =
|
221
221
|
value
|
222
222
|
|> Option.ofNonError
|
223
223
|
|> formatValue
|
@@ -236,7 +236,7 @@ type Dominoes() =
|
|
236
236
|
let twoElementList = value :?> JArray |> normalizeJArray
|
237
237
|
(twoElementList.Item 0, twoElementList.Item 1) |> string
|
238
238
|
|
239
|
-
override
|
239
|
+
override __.RenderInput (_, _, value) =
|
240
240
|
value :?> JArray
|
241
241
|
|> normalizeJArray
|
242
242
|
|> Seq.map formatAsTuple
|
@@ -247,7 +247,7 @@ type Dominoes() =
|
|
247
247
|
type Etl() =
|
248
248
|
inherit Exercise()
|
249
249
|
|
250
|
-
member
|
250
|
+
member __.formatMap<'TKey, 'TValue> (value: obj) =
|
251
251
|
let input = value :?> JObject
|
252
252
|
let dict = input.ToObject<Collections.Generic.Dictionary<'TKey, 'TValue>>();
|
253
253
|
let formattedList =
|
@@ -260,20 +260,20 @@ type Etl() =
|
|
260
260
|
else
|
261
261
|
sprintf "%s |> Map.ofList" formattedList
|
262
262
|
|
263
|
-
override this.RenderInput (
|
263
|
+
override this.RenderInput (_, _, value) = this.formatMap<int, List<char>> value
|
264
264
|
|
265
|
-
override this.RenderExpected (
|
265
|
+
override this.RenderExpected (_, _, value) = this.formatMap<char, int> value
|
266
266
|
|
267
267
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
268
268
|
|
269
269
|
type FoodChain() =
|
270
270
|
inherit Exercise()
|
271
271
|
|
272
|
-
override
|
272
|
+
override __.PropertiesUsedAsSutParameter _ = ["startVerse"; "endVerse"]
|
273
273
|
|
274
|
-
override
|
274
|
+
override __.PropertiesWithIdentifier _ = ["expected"]
|
275
275
|
|
276
|
-
override
|
276
|
+
override __.RenderExpected (_, _, value) =
|
277
277
|
(value :?> JArray)
|
278
278
|
|> normalizeJArray
|
279
279
|
|> Seq.map formatValue
|
@@ -282,40 +282,40 @@ type FoodChain() =
|
|
282
282
|
type Forth() =
|
283
283
|
inherit Exercise()
|
284
284
|
|
285
|
-
override
|
285
|
+
override __.PropertiesWithIdentifier _ = ["expected"]
|
286
286
|
|
287
|
-
override
|
287
|
+
override __.RenderExpected (_, _, value) =
|
288
288
|
value
|
289
289
|
|> Option.ofObj
|
290
290
|
|> formatValue
|
291
291
|
|
292
|
-
override
|
292
|
+
override __.IdentifierTypeAnnotation (_, _, value) =
|
293
293
|
match value :?> JArray|> Option.ofObj |> Option.map Seq.isEmpty with
|
294
294
|
| Some true -> Some "int list option"
|
295
295
|
| _ -> None
|
296
296
|
|
297
|
-
override
|
297
|
+
override __.UseFullMethodName _ = true
|
298
298
|
|
299
299
|
type Gigasecond() =
|
300
300
|
inherit Exercise()
|
301
301
|
|
302
|
-
override
|
302
|
+
override __.RenderExpected (_, _, value) = value :?> DateTime |> formatDateTime |> parenthesize
|
303
303
|
|
304
|
-
override
|
304
|
+
override __.RenderInput (canonicalDataCase, key, value) =
|
305
305
|
match key with
|
306
306
|
| "input" -> DateTime.Parse(string value, CultureInfo.InvariantCulture) |> formatDateTime |> parenthesize
|
307
307
|
| _ -> base.RenderInput (canonicalDataCase, key, value)
|
308
308
|
|
309
|
-
override
|
309
|
+
override __.AdditionalNamespaces = [typeof<DateTime>.Namespace]
|
310
310
|
|
311
311
|
type Grains() =
|
312
312
|
inherit Exercise()
|
313
313
|
|
314
|
-
override
|
314
|
+
override __.PropertiesWithIdentifier _ = ["expected"]
|
315
315
|
|
316
|
-
override
|
316
|
+
override __.IdentifierTypeAnnotation (_, _, _) = Some "Result<uint64,string>"
|
317
317
|
|
318
|
-
override
|
318
|
+
override __.RenderExpected (_, _, value) =
|
319
319
|
match string value with
|
320
320
|
| "-1" -> "Error \"Invalid input\""
|
321
321
|
| x -> sprintf "Ok %sUL" x
|
@@ -323,7 +323,7 @@ type Grains() =
|
|
323
323
|
type Hamming() =
|
324
324
|
inherit Exercise()
|
325
325
|
|
326
|
-
override
|
326
|
+
override __.RenderExpected (_, _, value) =
|
327
327
|
value
|
328
328
|
|> Option.ofNonError
|
329
329
|
|> formatValue
|
@@ -335,11 +335,11 @@ type HelloWorld() =
|
|
335
335
|
type House() =
|
336
336
|
inherit Exercise()
|
337
337
|
|
338
|
-
override
|
338
|
+
override __.PropertiesUsedAsSutParameter _ = ["startVerse"; "endVerse"]
|
339
339
|
|
340
|
-
override
|
340
|
+
override __.PropertiesWithIdentifier _ = ["expected"]
|
341
341
|
|
342
|
-
override
|
342
|
+
override __.RenderExpected (_, _, value) =
|
343
343
|
(value :?> JArray)
|
344
344
|
|> normalizeJArray
|
345
345
|
|> Seq.map formatValue
|
@@ -356,21 +356,21 @@ type KindergartenGarden() =
|
|
356
356
|
|
357
357
|
let toPlant (jToken: JToken) = sprintf "Plant.%s" (jToken.ToString() |> String.humanize)
|
358
358
|
|
359
|
-
override
|
359
|
+
override __.RenderExpected (_, _, value) =
|
360
360
|
value :?> JArray
|
361
361
|
|> Seq.map toPlant
|
362
362
|
|> formatList
|
363
363
|
|
364
|
-
override
|
364
|
+
override __.PropertiesWithIdentifier _ = ["student"; "diagram"; "expected"]
|
365
365
|
|
366
|
-
override
|
366
|
+
override __.UseFullMethodName _ = true
|
367
367
|
|
368
368
|
type LargestSeriesProduct() =
|
369
369
|
inherit Exercise()
|
370
370
|
|
371
371
|
override this.PropertiesWithIdentifier canonicalDataCase = this.PropertiesUsedAsSutParameter canonicalDataCase
|
372
372
|
|
373
|
-
override
|
373
|
+
override __.RenderExpected (_, _, value) =
|
374
374
|
value
|
375
375
|
|> Option.ofNonNegativeInt
|
376
376
|
|> formatValue
|
@@ -385,7 +385,7 @@ type Luhn() =
|
|
385
385
|
type Markdown() =
|
386
386
|
inherit Exercise()
|
387
387
|
|
388
|
-
override
|
388
|
+
override __.ToTestMethod (index, canonicalDataCase) =
|
389
389
|
{ base.ToTestMethod (index, canonicalDataCase) with Skip = false }
|
390
390
|
|
391
391
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
@@ -393,13 +393,13 @@ type Markdown() =
|
|
393
393
|
type Meetup() =
|
394
394
|
inherit Exercise()
|
395
395
|
|
396
|
-
override
|
396
|
+
override __.RenderExpected (canonicalDataCase, _, _) =
|
397
397
|
let year = canonicalDataCase.Properties.["year"] :?> int64 |> int
|
398
398
|
let month = canonicalDataCase.Properties.["month"] :?> int64 |> int
|
399
399
|
let day = canonicalDataCase.Properties.["dayofmonth"] :?> int64 |> int
|
400
400
|
DateTime(year, month, day) |> formatDateTime |> parenthesize
|
401
401
|
|
402
|
-
override
|
402
|
+
override __.RenderInput (canonicalDataCase, key, value) =
|
403
403
|
match key with
|
404
404
|
| "dayofweek" ->
|
405
405
|
sprintf "DayOfWeek.%s" (string canonicalDataCase.Properties.["dayofweek"])
|
@@ -408,10 +408,10 @@ type Meetup() =
|
|
408
408
|
| _ ->
|
409
409
|
base.RenderInput (canonicalDataCase, key, value)
|
410
410
|
|
411
|
-
override
|
411
|
+
override __.MapCanonicalDataCaseProperties (_, properties) =
|
412
412
|
properties |> Map.add "expected" null // Ensure that the "expected" key exists
|
413
413
|
|
414
|
-
override
|
414
|
+
override __.PropertiesUsedAsSutParameter _ =
|
415
415
|
["year"; "month"; "dayofweek"; "week"]
|
416
416
|
|
417
417
|
override this.AdditionalNamespaces = [typeof<DateTime>.Namespace]
|
@@ -419,7 +419,7 @@ type Meetup() =
|
|
419
419
|
type Minesweeper() =
|
420
420
|
inherit Exercise()
|
421
421
|
|
422
|
-
override
|
422
|
+
override __.RenderValueWithoutIdentifier (_, _, value) =
|
423
423
|
value :?> JArray
|
424
424
|
|> normalizeJArray
|
425
425
|
|> Seq.map formatValue
|
@@ -427,7 +427,7 @@ type Minesweeper() =
|
|
427
427
|
|
428
428
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
429
429
|
|
430
|
-
override
|
430
|
+
override __.IdentifierTypeAnnotation (_, _, value) =
|
431
431
|
match value :?> JArray |> Seq.isEmpty with
|
432
432
|
| true -> Some "string list"
|
433
433
|
| false -> None
|
@@ -435,7 +435,7 @@ type Minesweeper() =
|
|
435
435
|
type NthPrime() =
|
436
436
|
inherit Exercise()
|
437
437
|
|
438
|
-
override
|
438
|
+
override __.RenderExpected (_, _, value) =
|
439
439
|
value
|
440
440
|
|> Option.ofNonError
|
441
441
|
|> formatValue
|
@@ -444,7 +444,7 @@ type NthPrime() =
|
|
444
444
|
type NucleotideCount() =
|
445
445
|
inherit Exercise()
|
446
446
|
|
447
|
-
member
|
447
|
+
member __.formatMap<'TKey, 'TValue> (value: obj) =
|
448
448
|
match Option.ofNonError value with
|
449
449
|
| None ->
|
450
450
|
"None"
|
@@ -461,7 +461,7 @@ type NucleotideCount() =
|
|
461
461
|
else
|
462
462
|
sprintf "%s |> Map.ofList |> Some" formattedList
|
463
463
|
|
464
|
-
override this.RenderExpected (
|
464
|
+
override this.RenderExpected (_, _, value) = this.formatMap<char, int> value
|
465
465
|
|
466
466
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
467
467
|
|
@@ -470,13 +470,13 @@ type OcrNumbers() =
|
|
470
470
|
|
471
471
|
override this.PropertiesWithIdentifier canonicalDataCase = this.PropertiesUsedAsSutParameter canonicalDataCase
|
472
472
|
|
473
|
-
override
|
473
|
+
override __.RenderExpected (_, _, value) =
|
474
474
|
value
|
475
475
|
|> Option.ofNonNegativeInt
|
476
476
|
|> formatValue
|
477
477
|
|> parenthesizeOption
|
478
478
|
|
479
|
-
override
|
479
|
+
override __.RenderInput (_, _, value) =
|
480
480
|
value :?> JArray
|
481
481
|
|> normalizeJArray
|
482
482
|
|> Seq.map formatValue
|
@@ -504,21 +504,21 @@ type PalindromeProducts() =
|
|
504
504
|
|
505
505
|
sprintf "(%d, %s)" palindromeValue factors
|
506
506
|
|
507
|
-
override
|
507
|
+
override __.RenderExpected (_, _, value) =
|
508
508
|
value
|
509
509
|
|> Option.ofNonError
|
510
510
|
|> Option.map toPalindromeProducts
|
511
511
|
|> formatOption
|
512
512
|
|> parenthesizeOption
|
513
513
|
|
514
|
-
override
|
514
|
+
override __.PropertiesUsedAsSutParameter _ = ["input_min"; "input_max"]
|
515
515
|
|
516
516
|
type PascalsTriangle() =
|
517
517
|
inherit Exercise()
|
518
518
|
|
519
|
-
override
|
519
|
+
override __.PropertiesWithIdentifier _ = ["expected"]
|
520
520
|
|
521
|
-
override
|
521
|
+
override __.RenderExpected (_, _, value) =
|
522
522
|
match value with
|
523
523
|
| :? JArray ->
|
524
524
|
let formattedList =
|
@@ -533,7 +533,7 @@ type PascalsTriangle() =
|
|
533
533
|
sprintf "%s |> Some" formattedList
|
534
534
|
| _ -> "None"
|
535
535
|
|
536
|
-
override
|
536
|
+
override __.IdentifierTypeAnnotation (canonicalDataCase, key, value) =
|
537
537
|
match key, value with
|
538
538
|
| "expected", :? JArray ->
|
539
539
|
match value :?> JArray |> Seq.isEmpty with
|
@@ -541,14 +541,14 @@ type PascalsTriangle() =
|
|
541
541
|
| false -> None
|
542
542
|
| _ -> base.IdentifierTypeAnnotation (canonicalDataCase, key, value)
|
543
543
|
|
544
|
-
override
|
544
|
+
override __.ToTestMethodBodyAssertTemplate _ = "AssertEqual"
|
545
545
|
|
546
546
|
type PerfectNumbers() =
|
547
547
|
inherit Exercise()
|
548
548
|
|
549
549
|
let toClassification value = string value |> String.humanize
|
550
550
|
|
551
|
-
override
|
551
|
+
override __.RenderExpected (_, _, value) =
|
552
552
|
value
|
553
553
|
|> Option.ofNonError
|
554
554
|
|> Option.map toClassification
|
@@ -558,7 +558,7 @@ type PerfectNumbers() =
|
|
558
558
|
type PhoneNumber() =
|
559
559
|
inherit Exercise()
|
560
560
|
|
561
|
-
override
|
561
|
+
override __.RenderExpected (_, _, value) =
|
562
562
|
value
|
563
563
|
|> Option.ofObj
|
564
564
|
|> formatValue
|
@@ -570,26 +570,26 @@ type PigLatin() =
|
|
570
570
|
type Poker() =
|
571
571
|
inherit Exercise()
|
572
572
|
|
573
|
-
override
|
573
|
+
override __.PropertiesWithIdentifier _ = ["input"; "expected"]
|
574
574
|
|
575
575
|
type PrimeFactors() =
|
576
576
|
inherit Exercise()
|
577
577
|
|
578
|
-
override
|
578
|
+
override __.RenderInput (canonicalDataCase, key, value) =
|
579
579
|
base.RenderInput (canonicalDataCase, key, value) |> sprintf "%sL"
|
580
580
|
|
581
581
|
type Proverb() =
|
582
582
|
inherit Exercise()
|
583
583
|
|
584
|
-
override
|
584
|
+
override __.PropertiesWithIdentifier _ = ["input"; "expected"]
|
585
585
|
|
586
|
-
override
|
586
|
+
override __.RenderExpected (_, _, value) =
|
587
587
|
(value :?> JArray)
|
588
588
|
|> normalizeJArray
|
589
589
|
|> Seq.map formatValue
|
590
590
|
|> formatMultiLineList
|
591
591
|
|
592
|
-
override
|
592
|
+
override __.IdentifierTypeAnnotation (_, _, value) =
|
593
593
|
match value :?> JArray |> Seq.isEmpty with
|
594
594
|
| true -> Some "string list"
|
595
595
|
| false -> None
|
@@ -597,12 +597,12 @@ type Proverb() =
|
|
597
597
|
type QueenAttack() =
|
598
598
|
inherit Exercise()
|
599
599
|
|
600
|
-
override
|
600
|
+
override __.MapCanonicalDataCaseProperty (canonicalDataCase, key, value) =
|
601
601
|
match canonicalDataCase.Property, key, value with
|
602
602
|
| "create", "expected", _ -> value :?> int64 <> -1L |> box
|
603
603
|
| _ -> base.MapCanonicalDataCaseProperty (canonicalDataCase, key, value)
|
604
604
|
|
605
|
-
override
|
605
|
+
override __.RenderInput (canonicalDataCase, key, value) =
|
606
606
|
let parsePositionTuple (tupleValue: obj) =
|
607
607
|
let position = (tupleValue :?> JToken).SelectToken("position")
|
608
608
|
formatValue (position.["row"].ToObject<int>(), position.["column"].ToObject<int>())
|
@@ -611,12 +611,12 @@ type QueenAttack() =
|
|
611
611
|
| "queen" | "white_queen" | "black_queen" -> parsePositionTuple value
|
612
612
|
| _ -> base.RenderInput (canonicalDataCase, key, value)
|
613
613
|
|
614
|
-
override
|
614
|
+
override __.PropertiesWithIdentifier _ = ["white_queen"; "black_queen"]
|
615
615
|
|
616
616
|
type RailFenceCipher() =
|
617
617
|
inherit Exercise()
|
618
618
|
|
619
|
-
override
|
619
|
+
override __.PropertiesUsedAsSutParameter _ = ["rails"; "msg"]
|
620
620
|
|
621
621
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
622
622
|
|
@@ -626,7 +626,7 @@ type Raindrops() =
|
|
626
626
|
type Rectangles() =
|
627
627
|
inherit Exercise()
|
628
628
|
|
629
|
-
member private
|
629
|
+
member private __.GetPadding n =
|
630
630
|
String.replicate n " "
|
631
631
|
|
632
632
|
member private this.FormatList (list: List<string>) =
|
@@ -640,8 +640,8 @@ type Rectangles() =
|
|
640
640
|
else
|
641
641
|
sprintf "\n%s[ %s ]" (this.GetPadding 6) value
|
642
642
|
|
643
|
-
override
|
644
|
-
override
|
643
|
+
override __.PropertiesWithIdentifier _ = ["input"]
|
644
|
+
override __.RenderSutProperty _ = "rectangles"
|
645
645
|
|
646
646
|
override this.RenderValueWithoutIdentifier (canonicalDataCase, key, value) =
|
647
647
|
match key with
|
@@ -660,22 +660,22 @@ type RobotSimulator() =
|
|
660
660
|
|
661
661
|
let resultIdentifierName = "actual"
|
662
662
|
|
663
|
-
override
|
663
|
+
override __.PropertiesWithIdentifier _ = ["robot"; "property"; "expected"]
|
664
664
|
|
665
|
-
member private
|
665
|
+
member private __.RenderDirection (value: JToken) =
|
666
666
|
sprintf "%s" (value.ToObject<string>() |> String.upperCaseFirst)
|
667
667
|
|
668
|
-
member private
|
668
|
+
member private __.RenderCoords (coords: JToken) =
|
669
669
|
(coords.["x"].ToObject<int>(), coords.["y"].ToObject<int>())
|
670
670
|
|> formatValue
|
671
671
|
|
672
672
|
member private this.DefineRobot (direction: JToken) (coords: JToken) =
|
673
673
|
sprintf "createRobot %s %s" (this.RenderDirection direction) (this.RenderCoords coords)
|
674
674
|
|
675
|
-
member private
|
675
|
+
member private __.GetRobotProperties (value : JToken) =
|
676
676
|
value.SelectToken("direction"), value.SelectToken("position")
|
677
677
|
|
678
|
-
override
|
678
|
+
override __.RenderArrange canonicalDataCase =
|
679
679
|
// one identifier may be empty if we only checking created object
|
680
680
|
// we need to filter out this empty line
|
681
681
|
base.RenderArrange canonicalDataCase
|
@@ -685,7 +685,7 @@ type RobotSimulator() =
|
|
685
685
|
| v -> Some v
|
686
686
|
)
|
687
687
|
|
688
|
-
override this.RenderValueWithoutIdentifier (
|
688
|
+
override this.RenderValueWithoutIdentifier (_, key, value) =
|
689
689
|
match key with
|
690
690
|
| "robot" ->
|
691
691
|
let input = value :?> JToken
|
@@ -706,7 +706,7 @@ type RobotSimulator() =
|
|
706
706
|
""
|
707
707
|
| _ -> ""
|
708
708
|
|
709
|
-
override
|
709
|
+
override __.RenderValueWithIdentifier (canonicalDataCase, key, value) =
|
710
710
|
match key with
|
711
711
|
| "property" ->
|
712
712
|
let action = value :?> string
|
@@ -741,7 +741,7 @@ type RobotSimulator() =
|
|
741
741
|
| "create" -> "robot"
|
742
742
|
| _ -> resultIdentifierName
|
743
743
|
|
744
|
-
override
|
744
|
+
override __.RenderTestMethodName canonicalDataCase =
|
745
745
|
// avoid duplicated method names
|
746
746
|
// for this generator it is preferable
|
747
747
|
// because useFullMethodName leads to very long names
|
@@ -753,7 +753,7 @@ type RotationalCipher() =
|
|
753
753
|
type RnaTranscription() =
|
754
754
|
inherit Exercise()
|
755
755
|
|
756
|
-
override
|
756
|
+
override __.RenderExpected (_, _, value) =
|
757
757
|
value |> Option.ofObj |> formatValue |> parenthesizeOption
|
758
758
|
|
759
759
|
type RunLengthEncoding() =
|
@@ -783,7 +783,7 @@ type ScrabbleScore() =
|
|
783
783
|
type SpiralMatrix() =
|
784
784
|
inherit Exercise()
|
785
785
|
|
786
|
-
override
|
786
|
+
override __.RenderExpected (_, _, value) =
|
787
787
|
(value :?> JArray)
|
788
788
|
|> normalizeJArray
|
789
789
|
|> Seq.map formatValue
|
@@ -792,11 +792,11 @@ type SpiralMatrix() =
|
|
792
792
|
type TwelveDays() =
|
793
793
|
inherit Exercise()
|
794
794
|
|
795
|
-
override
|
795
|
+
override __.PropertiesUsedAsSutParameter _ = ["startVerse"; "endVerse"]
|
796
796
|
|
797
|
-
override
|
797
|
+
override __.PropertiesWithIdentifier _ = ["expected"]
|
798
798
|
|
799
|
-
override
|
799
|
+
override __.RenderExpected (_, _, value) =
|
800
800
|
(value :?> JArray)
|
801
801
|
|> normalizeJArray
|
802
802
|
|> Seq.map formatValue
|
@@ -805,5 +805,5 @@ type TwelveDays() =
|
|
805
805
|
type TwoFer() =
|
806
806
|
inherit Exercise()
|
807
807
|
|
808
|
-
override
|
808
|
+
override __.RenderInput (_, _, value) =
|
809
809
|
value |> Option.ofObj |> formatValue |> parenthesizeOption
|