trackler 2.2.1.134 → 2.2.1.135
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/series/canonical-data.json +105 -0
- data/problem-specifications/exercises/series/description.md +6 -6
- data/problem-specifications/exercises/sieve/description.md +5 -3
- data/tracks/ceylon/exercises/sieve/README.md +5 -3
- data/tracks/fsharp/.gitignore +1 -0
- data/tracks/fsharp/docs/GENERATORS.md +314 -0
- data/tracks/fsharp/generators/Exercise.fs +39 -80
- data/tracks/fsharp/generators/Generators.fs +42 -40
- data/tracks/fsharp/generators/Generators.fsproj.user +6 -0
- data/tracks/haskell/exercises/crypto-square/README.md +4 -5
- data/tracks/haskell/exercises/isbn-verifier/package.yaml +1 -1
- data/tracks/haskell/exercises/isbn-verifier/test/Tests.hs +4 -0
- data/tracks/haskell/exercises/kindergarten-garden/package.yaml +1 -1
- data/tracks/haskell/exercises/series/README.md +6 -6
- data/tracks/haskell/exercises/series/examples/success-byteseqs/src/Series.hs +6 -8
- data/tracks/haskell/exercises/series/examples/success-standard/src/Series.hs +0 -1
- data/tracks/haskell/exercises/series/package.yaml +1 -1
- data/tracks/haskell/exercises/series/test/Tests.hs +17 -2
- data/tracks/haskell/exercises/sieve/README.md +5 -3
- data/tracks/java/CONTRIBUTING.md +5 -6
- data/tracks/java/exercises/book-store/.meta/version +1 -1
- data/tracks/java/exercises/change/.meta/version +1 -1
- data/tracks/java/exercises/circular-buffer/.meta/version +1 -1
- data/tracks/java/exercises/custom-set/.meta/version +1 -1
- data/tracks/java/exercises/forth/.meta/version +1 -1
- data/tracks/java/exercises/list-ops/.meta/version +1 -1
- data/tracks/java/exercises/minesweeper/.meta/version +1 -1
- data/tracks/java/exercises/ocr-numbers/.meta/version +1 -1
- data/tracks/java/exercises/wordy/.meta/version +1 -1
- data/tracks/nim/config.json +57 -44
- data/tracks/nim/exercises/pangram/README.md +26 -0
- data/tracks/nim/exercises/pangram/example.nim +9 -0
- data/tracks/nim/exercises/pangram/pangram_test.nim +35 -0
- data/tracks/nim/exercises/roman-numerals/README.md +61 -0
- data/tracks/nim/exercises/roman-numerals/example.nim +30 -0
- data/tracks/nim/exercises/roman-numerals/roman_numerals_test.nim +28 -0
- data/tracks/nim/exercises/scrabble-score/README.md +57 -0
- data/tracks/nim/exercises/scrabble-score/example.nim +13 -0
- data/tracks/nim/exercises/scrabble-score/scrabble_score_test.nim +37 -0
- data/tracks/perl5/README.md +2 -1
- data/tracks/perl5/cpanfile +2 -1
- data/tracks/perl5/exercises/grains/.meta/exercise-data.yaml +55 -0
- data/tracks/perl5/exercises/grains/.meta/solutions/Grains.pm +15 -23
- data/tracks/perl5/exercises/grains/Grains.pm +13 -0
- data/tracks/perl5/exercises/grains/cpanfile +1 -0
- data/tracks/perl5/exercises/grains/grains.t +136 -75
- data/tracks/ruby/README.md +0 -6
- data/tracks/rust/.travis.yml +1 -1
- data/tracks/rust/_test/check-stubs.sh +0 -0
- data/tracks/rust/_test/count-ignores.sh +0 -0
- data/tracks/rust/_test/ensure-lib-src-rs-exist.sh +0 -0
- data/tracks/rust/_test/ensure-readmes-are-updated.sh +0 -0
- data/tracks/rust/_test/ensure-stubs-compile.sh +0 -0
- data/tracks/rust/_test/verify-exercise-difficulties.sh +52 -0
- data/tracks/rust/config.json +4 -4
- data/tracks/swift/exercises/space-age/Tests/SpaceAgeTests/SpaceAgeTests.swift +15 -15
- data/tracks/typescript/config.json +46 -1
- data/tracks/typescript/exercises/bowling/README.md +93 -0
- data/tracks/typescript/exercises/bowling/bowling.example.ts +77 -0
- data/tracks/typescript/exercises/bowling/bowling.test.ts +137 -0
- data/tracks/typescript/exercises/bowling/bowling.ts +0 -0
- data/tracks/typescript/exercises/bowling/package.json +36 -0
- data/tracks/typescript/exercises/bowling/tsconfig.json +22 -0
- data/tracks/typescript/exercises/bowling/tslint.json +127 -0
- data/tracks/typescript/exercises/bowling/yarn.lock +2624 -0
- data/tracks/typescript/exercises/connect/README.md +59 -0
- data/tracks/typescript/exercises/connect/connect.example.ts +77 -0
- data/tracks/typescript/exercises/connect/connect.test.ts +108 -0
- data/tracks/typescript/exercises/connect/connect.ts +0 -0
- data/tracks/typescript/exercises/connect/package.json +36 -0
- data/tracks/typescript/exercises/connect/tsconfig.json +22 -0
- data/tracks/typescript/exercises/connect/tslint.json +127 -0
- data/tracks/typescript/exercises/connect/yarn.lock +2624 -0
- data/tracks/typescript/exercises/rectangles/README.md +92 -0
- data/tracks/typescript/exercises/rectangles/package.json +36 -0
- data/tracks/typescript/exercises/rectangles/rectangles.example.ts +59 -0
- data/tracks/typescript/exercises/rectangles/rectangles.test.ts +134 -0
- data/tracks/typescript/exercises/rectangles/rectangles.ts +0 -0
- data/tracks/typescript/exercises/rectangles/tsconfig.json +22 -0
- data/tracks/typescript/exercises/rectangles/tslint.json +127 -0
- data/tracks/typescript/exercises/rectangles/yarn.lock +2624 -0
- metadata +42 -2
@@ -17,58 +17,26 @@ let private exerciseNameFromType (exerciseType: Type) = exerciseType.Name.Kebabe
|
|
17
17
|
[<AbstractClass>]
|
18
18
|
type GeneratorExercise() =
|
19
19
|
|
20
|
-
//
|
21
|
-
abstract member MapCanonicalData : CanonicalData -> CanonicalData
|
22
|
-
abstract member MapCanonicalDataCase : CanonicalDataCase -> CanonicalDataCase
|
23
|
-
abstract member MapCanonicalDataCaseInput : CanonicalDataCase * Map<string, obj> -> Map<string, obj>
|
24
|
-
abstract member MapCanonicalDataCaseInputProperty : CanonicalDataCase * string * obj -> obj
|
25
|
-
abstract member MapCanonicalDataCaseExpected : CanonicalDataCase * string * obj -> obj
|
26
|
-
|
27
|
-
// Convert canonical data to representation used when rendering
|
28
|
-
abstract member ToTestFile : CanonicalData -> TestFile
|
29
|
-
abstract member ToTestMethod : int * CanonicalDataCase -> TestMethod
|
30
|
-
abstract member ToTestMethodBody : CanonicalDataCase -> TestMethodBody
|
31
|
-
abstract member ToTestMethodBodyAssert : CanonicalDataCase -> TestMethodBodyAssert
|
32
|
-
|
33
|
-
// Determine the templates to use when rendering
|
34
|
-
abstract member TestFileTemplate : string
|
35
|
-
abstract member TestMethodTemplate : int * CanonicalDataCase -> string
|
36
|
-
abstract member TestMethodBodyTemplate : CanonicalDataCase -> string
|
37
|
-
abstract member TestMethodBodyAssertTemplate : CanonicalDataCase -> string
|
38
|
-
abstract member TestFileFormat: TestFileFormat
|
39
|
-
|
40
|
-
// Rendering of canonical data
|
41
|
-
abstract member Render : CanonicalData -> string
|
42
|
-
abstract member RenderTestMethod : int * CanonicalDataCase -> string
|
43
|
-
abstract member RenderTestMethodBody : CanonicalDataCase -> string
|
44
|
-
abstract member RenderTestMethodName : CanonicalDataCase -> string
|
45
|
-
abstract member RenderSetup : CanonicalData -> string
|
46
|
-
|
47
|
-
// Generic value/identifier rendering methods
|
48
|
-
abstract member RenderValue : CanonicalDataCase * string * obj -> string
|
49
|
-
abstract member RenderValueOrIdentifier: CanonicalDataCase * string * obj -> string
|
50
|
-
abstract member RenderValueWithoutIdentifier: CanonicalDataCase * string * obj -> string
|
51
|
-
abstract member RenderValueWithIdentifier: CanonicalDataCase * string * obj -> string
|
52
|
-
abstract member RenderIdentifier: CanonicalDataCase * string * obj -> string
|
53
|
-
abstract member RenderIdentifierWithTypeAnnotation: CanonicalDataCase * string * obj -> string
|
54
|
-
|
55
|
-
// Canonical-data specific rendering methods
|
20
|
+
// Customize rendered output
|
56
21
|
abstract member RenderExpected : CanonicalDataCase * string * obj -> string
|
57
22
|
abstract member RenderInput : CanonicalDataCase * string * obj -> string
|
58
23
|
abstract member RenderArrange : CanonicalDataCase -> string list
|
59
24
|
abstract member RenderAssert : CanonicalDataCase -> string list
|
60
25
|
abstract member RenderSut : CanonicalDataCase -> string
|
61
|
-
abstract member
|
62
|
-
abstract member
|
63
|
-
abstract member RenderSutProperty : CanonicalDataCase -> string
|
26
|
+
abstract member RenderSetup : CanonicalData -> string
|
27
|
+
abstract member RenderValue : CanonicalDataCase * string * obj -> string
|
64
28
|
|
65
29
|
// Utility methods to customize rendered output
|
66
|
-
abstract member
|
30
|
+
abstract member MapCanonicalDataCase : CanonicalDataCase -> CanonicalDataCase
|
67
31
|
abstract member PropertiesUsedAsSutParameter : CanonicalDataCase -> string list
|
68
32
|
abstract member PropertiesWithIdentifier : CanonicalDataCase -> string list
|
69
|
-
abstract member IdentifierTypeAnnotation: CanonicalDataCase * string * obj -> string option
|
33
|
+
abstract member IdentifierTypeAnnotation: CanonicalDataCase * string * obj -> string option
|
34
|
+
abstract member AdditionalNamespaces : string list
|
35
|
+
abstract member AssertTemplate : CanonicalDataCase -> string
|
36
|
+
abstract member TestFileFormat: TestFileFormat
|
37
|
+
abstract member TestMethodName : CanonicalDataCase -> string
|
70
38
|
abstract member UseFullMethodName : CanonicalDataCase -> bool
|
71
|
-
abstract member
|
39
|
+
abstract member SkipTestMethod : int * CanonicalDataCase -> bool
|
72
40
|
|
73
41
|
member this.Name = this.GetType() |> exerciseNameFromType
|
74
42
|
member this.TestModuleName = this.GetType().Name.Pascalize() |> sprintf "%sTest"
|
@@ -88,25 +56,14 @@ type GeneratorExercise() =
|
|
88
56
|
|
89
57
|
// Allow changes in canonical data
|
90
58
|
|
91
|
-
|
59
|
+
member this.MapCanonicalData canonicalData =
|
92
60
|
{ canonicalData with Cases = List.map this.MapCanonicalDataCase canonicalData.Cases }
|
93
61
|
|
94
|
-
default
|
95
|
-
{ canonicalDataCase with
|
96
|
-
Input = this.MapCanonicalDataCaseInput (canonicalDataCase, canonicalDataCase.Input)
|
97
|
-
Expected = this.MapCanonicalDataCaseExpected (canonicalDataCase, "expected", canonicalDataCase.Expected) }
|
98
|
-
|
99
|
-
default this.MapCanonicalDataCaseInput (canonicalDataCase, properties) =
|
100
|
-
properties
|
101
|
-
|> Map.map (fun key value -> this.MapCanonicalDataCaseInputProperty (canonicalDataCase, key, value))
|
102
|
-
|
103
|
-
default __.MapCanonicalDataCaseInputProperty (_, _, value) = value
|
104
|
-
|
105
|
-
default __.MapCanonicalDataCaseExpected (_, _, value) = value
|
62
|
+
default __.MapCanonicalDataCase canonicalDataCase = canonicalDataCase
|
106
63
|
|
107
64
|
// Convert canonical data to representation used when rendering
|
108
65
|
|
109
|
-
|
66
|
+
member this.ToTestFile canonicalData =
|
110
67
|
let renderTestMethod i canonicalDataCase = this.RenderTestMethod(i, canonicalDataCase)
|
111
68
|
|
112
69
|
{ Version = canonicalData.Version
|
@@ -117,37 +74,37 @@ type GeneratorExercise() =
|
|
117
74
|
Methods = List.mapi renderTestMethod canonicalData.Cases
|
118
75
|
Setup = this.RenderSetup canonicalData }
|
119
76
|
|
120
|
-
|
121
|
-
{ Skip = index
|
122
|
-
Name = this.
|
77
|
+
member this.ToTestMethod (index, canonicalDataCase) =
|
78
|
+
{ Skip = this.SkipTestMethod (index, canonicalDataCase)
|
79
|
+
Name = this.TestMethodName canonicalDataCase
|
123
80
|
Body = this.RenderTestMethodBody canonicalDataCase }
|
124
81
|
|
125
|
-
|
82
|
+
member this.ToTestMethodBody canonicalDataCase =
|
126
83
|
{ Arrange = this.RenderArrange canonicalDataCase
|
127
84
|
Assert = this.RenderAssert canonicalDataCase }
|
128
85
|
|
129
|
-
|
86
|
+
member this.ToTestMethodBodyAssert canonicalDataCase =
|
130
87
|
{ Sut = this.RenderValueOrIdentifier (canonicalDataCase, "sut", canonicalDataCase.Expected)
|
131
88
|
Expected = this.RenderValueOrIdentifier (canonicalDataCase, "expected", canonicalDataCase.Expected) }
|
132
89
|
|
133
90
|
// Determine the templates to use when rendering
|
134
91
|
|
135
|
-
|
92
|
+
member this.TestFileTemplate =
|
136
93
|
match this.TestFileFormat with
|
137
94
|
| Module -> "TestModule"
|
138
95
|
| Class -> "TestClass"
|
139
96
|
|
140
|
-
|
97
|
+
member this.TestMethodTemplate (_, _) =
|
141
98
|
match this.TestFileFormat with
|
142
99
|
| Module -> "TestFunction"
|
143
100
|
| Class -> "TestMember"
|
144
101
|
|
145
|
-
|
102
|
+
member this.TestMethodBodyTemplate _ =
|
146
103
|
match this.TestFileFormat with
|
147
104
|
| Module -> "TestFunctionBody"
|
148
105
|
| Class -> "TestMemberBody"
|
149
106
|
|
150
|
-
default this.
|
107
|
+
default this.AssertTemplate canonicalDataCase =
|
151
108
|
match canonicalDataCase.Expected with
|
152
109
|
| :? JArray as jArray when jArray.Count = 0 && not (List.contains "expected" (this.PropertiesWithIdentifier canonicalDataCase)) -> "AssertEmpty"
|
153
110
|
| _ -> "AssertEqual"
|
@@ -156,26 +113,26 @@ type GeneratorExercise() =
|
|
156
113
|
|
157
114
|
// Rendering of canonical data
|
158
115
|
|
159
|
-
|
116
|
+
member this.Render canonicalData =
|
160
117
|
canonicalData
|
161
118
|
|> this.ToTestFile
|
162
119
|
|> renderPartialTemplate this.TestFileTemplate
|
163
120
|
|
164
|
-
|
121
|
+
member this.RenderTestMethod (index, canonicalDataCase) =
|
165
122
|
let template = this.TestMethodTemplate (index, canonicalDataCase)
|
166
123
|
|
167
124
|
(index, canonicalDataCase)
|
168
125
|
|> this.ToTestMethod
|
169
126
|
|> renderPartialTemplate template
|
170
127
|
|
171
|
-
|
128
|
+
member this.RenderTestMethodBody canonicalDataCase =
|
172
129
|
let template = this.TestMethodBodyTemplate canonicalDataCase
|
173
130
|
|
174
131
|
canonicalDataCase
|
175
132
|
|> this.ToTestMethodBody
|
176
133
|
|> renderPartialTemplate template
|
177
134
|
|
178
|
-
default this.
|
135
|
+
default this.TestMethodName canonicalDataCase =
|
179
136
|
match this.UseFullMethodName canonicalDataCase with
|
180
137
|
| false ->
|
181
138
|
String.upperCaseFirst canonicalDataCase.Description
|
@@ -190,27 +147,27 @@ type GeneratorExercise() =
|
|
190
147
|
|
191
148
|
default __.RenderValue (_, _, value) = formatValue value
|
192
149
|
|
193
|
-
|
150
|
+
member this.RenderValueOrIdentifier (canonicalDataCase, key, value) =
|
194
151
|
let properties = this.PropertiesWithIdentifier canonicalDataCase
|
195
152
|
|
196
153
|
match List.contains key properties with
|
197
154
|
| true -> this.RenderIdentifier (canonicalDataCase, key, value)
|
198
155
|
| false -> this.RenderValueWithoutIdentifier (canonicalDataCase, key, value)
|
199
156
|
|
200
|
-
|
157
|
+
member this.RenderValueWithoutIdentifier (canonicalDataCase, key, value) =
|
201
158
|
match key with
|
202
159
|
| "expected" -> this.RenderExpected (canonicalDataCase, key, value)
|
203
160
|
| "sut" -> this.RenderSut canonicalDataCase
|
204
161
|
| _ -> this.RenderInput (canonicalDataCase, key, value)
|
205
162
|
|
206
|
-
|
163
|
+
member this.RenderValueWithIdentifier (canonicalDataCase, key, value) =
|
207
164
|
let identifier = this.RenderIdentifierWithTypeAnnotation (canonicalDataCase, key, value)
|
208
165
|
let value = this.RenderValueWithoutIdentifier (canonicalDataCase, key, value)
|
209
166
|
sprintf "let %s = %s" identifier value
|
210
167
|
|
211
|
-
|
168
|
+
member __.RenderIdentifier (_, key, _) = String.camelize key
|
212
169
|
|
213
|
-
|
170
|
+
member this.RenderIdentifierWithTypeAnnotation (canonicalDataCase, key, value) =
|
214
171
|
let identifier = this.RenderIdentifier (canonicalDataCase, key, value)
|
215
172
|
|
216
173
|
match this.IdentifierTypeAnnotation (canonicalDataCase, key, value) with
|
@@ -248,31 +205,31 @@ type GeneratorExercise() =
|
|
248
205
|
|> List.choose renderArrangeProperty
|
249
206
|
|
250
207
|
default this.RenderAssert canonicalDataCase =
|
251
|
-
let template = this.
|
208
|
+
let template = this.AssertTemplate canonicalDataCase
|
252
209
|
|
253
210
|
canonicalDataCase
|
254
211
|
|> this.ToTestMethodBodyAssert
|
255
212
|
|> renderPartialTemplate template
|
256
213
|
|> List.singleton
|
257
214
|
|
258
|
-
default this.RenderSut canonicalDataCase =
|
215
|
+
default this.RenderSut canonicalDataCase =
|
259
216
|
let parameters = this.RenderSutParameters canonicalDataCase
|
260
217
|
let prop = this.RenderSutProperty canonicalDataCase
|
261
218
|
prop :: parameters |> String.concat " "
|
262
219
|
|
263
|
-
|
220
|
+
member this.RenderSutParameters canonicalDataCase =
|
264
221
|
let sutParameterProperties = this.PropertiesUsedAsSutParameter canonicalDataCase
|
265
222
|
let renderSutParameter key = this.RenderSutParameter (canonicalDataCase, key, Map.find key canonicalDataCase.Input)
|
266
223
|
|
267
224
|
sutParameterProperties
|
268
225
|
|> List.map renderSutParameter
|
269
226
|
|
270
|
-
|
227
|
+
member this.RenderSutParameter (canonicalDataCase, key, value) =
|
271
228
|
this.RenderValueOrIdentifier (canonicalDataCase, key, value)
|
272
229
|
|
273
|
-
|
230
|
+
member __.RenderSutProperty canonicalDataCase = string canonicalDataCase.Property
|
274
231
|
|
275
|
-
|
232
|
+
member this.Properties canonicalDataCase =
|
276
233
|
List.append (this.PropertiesUsedAsSutParameter canonicalDataCase) ["expected"]
|
277
234
|
|
278
235
|
default __.PropertiesUsedAsSutParameter canonicalDataCase =
|
@@ -289,6 +246,8 @@ type GeneratorExercise() =
|
|
289
246
|
default __.UseFullMethodName _ = false
|
290
247
|
|
291
248
|
default __.AdditionalNamespaces = []
|
249
|
+
|
250
|
+
default __.SkipTestMethod (index, _) = index > 0
|
292
251
|
|
293
252
|
type CustomExercise() =
|
294
253
|
|
@@ -106,7 +106,7 @@ type BinarySearch() =
|
|
106
106
|
|
107
107
|
override __.PropertiesWithIdentifier _ = ["array"; "value"; "expected"]
|
108
108
|
|
109
|
-
override __.
|
109
|
+
override __.RenderValue (canonicalDataCase, key, value) =
|
110
110
|
match key with
|
111
111
|
| "array" ->
|
112
112
|
(value :?> JToken).ToObject<string []>() |> formatArray
|
@@ -115,7 +115,7 @@ type BinarySearch() =
|
|
115
115
|
| "-1" -> None |> formatOption
|
116
116
|
| x -> Some x |> formatOption
|
117
117
|
| _ ->
|
118
|
-
base.
|
118
|
+
base.RenderValue (canonicalDataCase, key, value)
|
119
119
|
|
120
120
|
type BinarySearchTree() =
|
121
121
|
inherit GeneratorExercise()
|
@@ -281,21 +281,21 @@ type CircularBuffer() =
|
|
281
281
|
type Clock() =
|
282
282
|
inherit GeneratorExercise()
|
283
283
|
|
284
|
-
let createClock (value:obj)
|
284
|
+
let createClock (value:obj) =
|
285
285
|
let clock = value :?> JObject
|
286
286
|
let hour = clock.["hour"].ToObject<string>()
|
287
287
|
let minute = clock.["minute"].ToObject<string>()
|
288
|
-
sprintf "
|
288
|
+
sprintf "create %s %s" hour minute
|
289
289
|
|
290
290
|
member private this.RenderPropertyValue canonicalDataCase property =
|
291
291
|
this.RenderSutParameter (canonicalDataCase, property, Map.find property canonicalDataCase.Input)
|
292
292
|
|
293
293
|
override __.PropertiesWithIdentifier _ = ["clock1"; "clock2"]
|
294
294
|
|
295
|
-
override __.
|
295
|
+
override __.RenderValue (canonicalDataCase, key, value) =
|
296
296
|
match key with
|
297
|
-
| "clock1" | "clock2" -> createClock value
|
298
|
-
| _ -> base.
|
297
|
+
| "clock1" | "clock2" -> createClock value
|
298
|
+
| _ -> base.RenderValue (canonicalDataCase, key, value)
|
299
299
|
|
300
300
|
override this.RenderArrange canonicalDataCase =
|
301
301
|
match canonicalDataCase.Property with
|
@@ -396,7 +396,7 @@ type CustomSet() =
|
|
396
396
|
|
397
397
|
member __.SutName = "actual"
|
398
398
|
|
399
|
-
override __.
|
399
|
+
override __.AssertTemplate _ = "AssertEqual"
|
400
400
|
|
401
401
|
member __.RenderSet (jToken: obj) =
|
402
402
|
(jToken :?> JToken).ToObject<seq<string>>()
|
@@ -492,8 +492,8 @@ type Etl() =
|
|
492
492
|
|
493
493
|
override this.RenderExpected (_, _, value) = this.FormatMap<char, int> value
|
494
494
|
|
495
|
-
override __.
|
496
|
-
Map.empty |> Map.add "lettersByScore" (canonicalDataCase.Properties.["input"])
|
495
|
+
override __.MapCanonicalDataCase canonicalDataCase =
|
496
|
+
{ canonicalDataCase with Input = Map.empty |> Map.add "lettersByScore" (canonicalDataCase.Properties.["input"]) }
|
497
497
|
|
498
498
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
499
499
|
|
@@ -586,10 +586,10 @@ type GoCounting() =
|
|
586
586
|
|> Map.remove "y"
|
587
587
|
|> Map.add "position" (territoryPosition input)
|
588
588
|
|
589
|
-
override __.
|
589
|
+
override __.MapCanonicalDataCase canonicalDataCase =
|
590
590
|
match canonicalDataCase.Property with
|
591
|
-
| "territory" -> mapTerritoryInput
|
592
|
-
| _ ->
|
591
|
+
| "territory" -> { canonicalDataCase with Input = mapTerritoryInput canonicalDataCase.Input }
|
592
|
+
| _ -> canonicalDataCase
|
593
593
|
|
594
594
|
override __.RenderInput (canonicalDataCase, key, value) =
|
595
595
|
match key with
|
@@ -736,7 +736,7 @@ type ListOps() =
|
|
736
736
|
| "function" -> renderFunction value
|
737
737
|
| _ -> base.RenderInput (canonicalDataCase, key, value)
|
738
738
|
|
739
|
-
override __.
|
739
|
+
override __.TestMethodName canonicalDataCase =
|
740
740
|
sprintf "%s %s" canonicalDataCase.Property canonicalDataCase.Description
|
741
741
|
|
742
742
|
type Luhn() =
|
@@ -745,8 +745,7 @@ type Luhn() =
|
|
745
745
|
type Markdown() =
|
746
746
|
inherit GeneratorExercise()
|
747
747
|
|
748
|
-
override __.
|
749
|
-
{ base.ToTestMethod (index, canonicalDataCase) with Skip = false }
|
748
|
+
override __.SkipTestMethod (_, _) = false
|
750
749
|
|
751
750
|
override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
|
752
751
|
|
@@ -901,7 +900,7 @@ type PascalsTriangle() =
|
|
901
900
|
| false -> None
|
902
901
|
| _ -> base.IdentifierTypeAnnotation (canonicalDataCase, key, value)
|
903
902
|
|
904
|
-
override __.
|
903
|
+
override __.AssertTemplate _ = "AssertEqual"
|
905
904
|
|
906
905
|
type PerfectNumbers() =
|
907
906
|
inherit GeneratorExercise()
|
@@ -1044,10 +1043,10 @@ type Proverb() =
|
|
1044
1043
|
type QueenAttack() =
|
1045
1044
|
inherit GeneratorExercise()
|
1046
1045
|
|
1047
|
-
override __.
|
1046
|
+
override __.RenderExpected (canonicalDataCase, key, value) =
|
1048
1047
|
match canonicalDataCase.Property with
|
1049
|
-
| "create" -> value :?> int64 <> -1L |>
|
1050
|
-
| _ -> base.
|
1048
|
+
| "create" -> value :?> int64 <> -1L |> formatValue
|
1049
|
+
| _ -> base.RenderExpected (canonicalDataCase, key, value)
|
1051
1050
|
|
1052
1051
|
override __.RenderInput (canonicalDataCase, key, value) =
|
1053
1052
|
let parsePositionTuple (tupleValue: obj) =
|
@@ -1078,10 +1077,10 @@ type RationalNumbers() =
|
|
1078
1077
|
| :? JArray as jArray -> sprintf "(create %d %d)" (jArray.[0].Value<int>()) (jArray.[1].Value<int>())
|
1079
1078
|
| _ -> base.RenderValue (canonicalDataCase, key, value)
|
1080
1079
|
|
1081
|
-
override __.
|
1080
|
+
override __.AssertTemplate canonicalDataCase =
|
1082
1081
|
match canonicalDataCase.Expected with
|
1083
1082
|
| :? double -> "AssertEqualWithin"
|
1084
|
-
| _ -> base.
|
1083
|
+
| _ -> base.AssertTemplate(canonicalDataCase)
|
1085
1084
|
|
1086
1085
|
type React() =
|
1087
1086
|
inherit GeneratorExercise()
|
@@ -1208,13 +1207,17 @@ type RobotSimulator() =
|
|
1208
1207
|
| Some _, Some _ -> ["expected"]
|
1209
1208
|
| None, None -> ["sut"; "expected"]
|
1210
1209
|
|
1211
|
-
override
|
1212
|
-
let
|
1210
|
+
override this.RenderAssert canonicalDataCase =
|
1211
|
+
let renderAssertWithProperty prop =
|
1212
|
+
let expected = this.RenderExpected (canonicalDataCase, "expected", canonicalDataCase.Expected)
|
1213
|
+
|
1214
|
+
{ Sut = sprintf "sut.%s" prop; Expected = expected }
|
1215
|
+
|> renderPartialTemplate "AssertEqual"
|
1213
1216
|
|
1214
1217
|
match parseInput canonicalDataCase.Expected with
|
1215
|
-
| None, Some _ ->
|
1216
|
-
| Some _, None ->
|
1217
|
-
| _ ->
|
1218
|
+
| None, Some _ -> [renderAssertWithProperty "position"]
|
1219
|
+
| Some _, None -> [renderAssertWithProperty "direction"]
|
1220
|
+
| _ -> base.RenderAssert canonicalDataCase
|
1218
1221
|
|
1219
1222
|
override __.RenderArrange canonicalDataCase =
|
1220
1223
|
sprintf "let robot = %s" (canonicalDataCase.Properties.["input"] |> parseInput |> renderInput) :: base.RenderArrange canonicalDataCase
|
@@ -1229,8 +1232,8 @@ type RobotSimulator() =
|
|
1229
1232
|
| "instructions" -> sprintf "instructions %s robot" (formatValue canonicalDataCase.Input.["instructions"])
|
1230
1233
|
| _ -> base.RenderSut canonicalDataCase
|
1231
1234
|
|
1232
|
-
override __.
|
1233
|
-
let testMethodName = base.
|
1235
|
+
override __.TestMethodName canonicalDataCase =
|
1236
|
+
let testMethodName = base.TestMethodName canonicalDataCase
|
1234
1237
|
|
1235
1238
|
match canonicalDataCase.Property with
|
1236
1239
|
| "create" | "instructions" -> testMethodName
|
@@ -1256,10 +1259,10 @@ type RunLengthEncoding() =
|
|
1256
1259
|
| _ ->
|
1257
1260
|
base.RenderSut canonicalDataCase
|
1258
1261
|
|
1259
|
-
override __.
|
1262
|
+
override __.TestMethodName canonicalDataCase =
|
1260
1263
|
match canonicalDataCase.Property with
|
1261
1264
|
| "consistency" ->
|
1262
|
-
base.
|
1265
|
+
base.TestMethodName canonicalDataCase
|
1263
1266
|
| _ ->
|
1264
1267
|
sprintf "%s %s" canonicalDataCase.Property canonicalDataCase.Description |> String.upperCaseFirst
|
1265
1268
|
|
@@ -1299,11 +1302,11 @@ type Say() =
|
|
1299
1302
|
type ScaleGenerator() =
|
1300
1303
|
inherit GeneratorExercise()
|
1301
1304
|
|
1302
|
-
override __.
|
1303
|
-
let input =
|
1305
|
+
override __.MapCanonicalDataCase canonicalDataCase =
|
1306
|
+
let input = canonicalDataCase.Input
|
1304
1307
|
match Map.tryFind "intervals" input with
|
1305
|
-
| Some _ ->
|
1306
|
-
| None -> Map.add "intervals" null input
|
1308
|
+
| Some _ -> canonicalDataCase
|
1309
|
+
| None -> { canonicalDataCase with Input = Map.add "intervals" null input }
|
1307
1310
|
|
1308
1311
|
override __.RenderInput (canonicalDataCase, key, value) =
|
1309
1312
|
match key with
|
@@ -1407,9 +1410,9 @@ type Triangle() =
|
|
1407
1410
|
canonicalDataCase.Description.Contains "isosceles" ||
|
1408
1411
|
canonicalDataCase.Description.Contains "scalene"
|
1409
1412
|
|
1410
|
-
override __.
|
1413
|
+
override __.TestMethodName canonicalDataCase =
|
1411
1414
|
match hasUniqueTestMethodName canonicalDataCase with
|
1412
|
-
| true -> base.
|
1415
|
+
| true -> base.TestMethodName canonicalDataCase
|
1413
1416
|
| false -> sprintf "%s returns %s" (String.upperCaseFirst canonicalDataCase.Property) canonicalDataCase.Description
|
1414
1417
|
|
1415
1418
|
override __.RenderInput (_, _, value) =
|
@@ -1640,6 +1643,5 @@ type Zipper() =
|
|
1640
1643
|
let expected = canonicalDataCase.Expected :?> JObject |> renderExpected
|
1641
1644
|
[tree; sut; expected]
|
1642
1645
|
|
1643
|
-
override __.
|
1644
|
-
|
1645
|
-
testMethodName.Replace("Set_", "Set ")
|
1646
|
+
override __.TestMethodName canonicalDataCase =
|
1647
|
+
base.TestMethodName canonicalDataCase |> String.replace "Set_" "Set "
|