trackler 2.2.1.27 → 2.2.1.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/palindrome-products/canonical-data.json +138 -0
  4. data/tracks/csharp/exercises/book-store/BookStoreTest.cs +26 -26
  5. data/tracks/csharp/exercises/complex-numbers/ComplexNumbersTest.cs +38 -38
  6. data/tracks/csharp/generators/Exercises/AllYourBase.cs +0 -2
  7. data/tracks/csharp/generators/Exercises/Allergies.cs +5 -23
  8. data/tracks/csharp/generators/Exercises/Alphametics.cs +6 -9
  9. data/tracks/csharp/generators/Exercises/Anagram.cs +1 -8
  10. data/tracks/csharp/generators/Exercises/BinarySearch.cs +2 -7
  11. data/tracks/csharp/generators/Exercises/BookStore.cs +2 -6
  12. data/tracks/csharp/generators/Exercises/BracketPush.cs +1 -1
  13. data/tracks/csharp/generators/Exercises/CollatzConjecture.cs +1 -3
  14. data/tracks/csharp/generators/Exercises/ComplexNumbers.cs +19 -46
  15. data/tracks/csharp/generators/Exercises/Convert.cs +7 -0
  16. data/tracks/csharp/generators/Exercises/CryptoSquare.cs +0 -4
  17. data/tracks/csharp/generators/Exercises/FoodChain.cs +1 -1
  18. data/tracks/csharp/generators/Exercises/Gigasecond.cs +5 -13
  19. data/tracks/csharp/generators/Exercises/Grains.cs +2 -10
  20. data/tracks/csharp/generators/Exercises/Hamming.cs +0 -2
  21. data/tracks/csharp/generators/Exercises/House.cs +1 -1
  22. data/tracks/csharp/generators/Exercises/PerfectNumbers.cs +2 -3
  23. data/tracks/csharp/generators/Exercises/Poker.cs +0 -3
  24. data/tracks/csharp/generators/Exercises/QueenAttack.cs +10 -21
  25. data/tracks/csharp/generators/Exercises/RailFenceCipher.cs +2 -7
  26. data/tracks/csharp/generators/Exercises/RnaTranscription.cs +0 -2
  27. data/tracks/csharp/generators/Exercises/SecretHandshake.cs +1 -10
  28. data/tracks/csharp/generators/Exercises/Sieve.cs +1 -1
  29. data/tracks/csharp/generators/Exercises/SpaceAge.cs +3 -8
  30. data/tracks/csharp/generators/Exercises/SumOfMultiples.cs +1 -17
  31. data/tracks/csharp/generators/Exercises/Transpose.cs +3 -6
  32. data/tracks/csharp/generators/Exercises/WordCount.cs +6 -9
  33. data/tracks/csharp/generators/Input/CanonicalDataCase.cs +26 -32
  34. data/tracks/csharp/generators/Input/CanonicalDataCaseJson.cs +73 -0
  35. data/tracks/csharp/generators/Input/CanonicalDataCaseJsonConverter.cs +7 -15
  36. data/tracks/csharp/generators/Input/CanonicalDataCasesJson.cs +58 -0
  37. data/tracks/csharp/generators/Input/CanonicalDataCasesJsonConverter.cs +3 -11
  38. data/tracks/csharp/generators/Output/TestMethodBodyData.cs +1 -1
  39. data/tracks/csharp/generators/Output/ValueFormatter.cs +2 -6
  40. data/tracks/ecmascript/README.md +1 -1
  41. data/tracks/go/README.md +3 -3
  42. data/tracks/go/exercises/robot-simulator/robot_simulator_step2_test.go +4 -4
  43. data/tracks/go/exercises/roman-numerals/example.go +2 -2
  44. data/tracks/go/exercises/roman-numerals/roman_numerals_test.go +3 -3
  45. data/tracks/ocaml/.travis-ci.sh +1 -1
  46. data/tracks/ocaml/config.json +432 -423
  47. data/tracks/ocaml/exercises/palindrome-products/.merlin +3 -0
  48. data/tracks/ocaml/exercises/palindrome-products/Makefile +11 -0
  49. data/tracks/ocaml/exercises/palindrome-products/README.md +85 -0
  50. data/tracks/ocaml/exercises/palindrome-products/example.ml +59 -0
  51. data/tracks/ocaml/exercises/palindrome-products/palindrome_products.mli +22 -0
  52. data/tracks/ocaml/exercises/palindrome-products/test.ml +58 -0
  53. data/tracks/ocaml/tools/test-generator/src/ocaml_special_cases.ml +28 -3
  54. data/tracks/ocaml/tools/test-generator/templates/ocaml/palindrome-products/test.ml +25 -0
  55. data/tracks/typescript/config.json +160 -112
  56. metadata +13 -3
  57. data/tracks/csharp/generators/Exercises/ConvertExtensions.cs +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eba2a1d8fc60987a49bd6540cf30c56d898dfe20
4
- data.tar.gz: 2069c1589727e3589cecae15f17e43a754775bd2
3
+ metadata.gz: c3a805b6e7e811932f76b9d6546d5aed224b27fe
4
+ data.tar.gz: f782c09ccca7e40a7beaa87d7519b7646046f29b
5
5
  SHA512:
6
- metadata.gz: f2f016ddebdcd29c9fb0ae96a094ce764608fb8ccc6606ee11f4ddaef15ba301db50f66376546e2d9943a834a91365843afdf858221a917a79c7a69569d7f29d
7
- data.tar.gz: 56edea83d76ba56b4761b77a6a506b485d9582ae2ca9e3ea800f766b551561d0d3b2e09d345a8ea791a81bfa1587ac46c8006c386725c0a717f94225d2cfe09e
6
+ metadata.gz: c09dd81f75ca8b03185a1cb660ecf868d71fa3cba133f530a7893ef7928c110e0e119584d4c652d1b39b35bf934bb5139f3419d81284fb8f79d5ec96d6d17e4c
7
+ data.tar.gz: 351bf0b1cc22a89c2e1e72d784f60f58271f248aed4e5e97ee926db9e457ae45037bcca81dcca81322b6dd83f5823dcd61bf7f5027e84921c26d1ed22b825a64
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.2.1.27"
2
+ VERSION = "2.2.1.28"
3
3
  end
@@ -0,0 +1,138 @@
1
+ {
2
+ "exercise": "palindrome-products",
3
+ "version": "1.0.0",
4
+ "cases": [{
5
+ "description": "finds the smallest palindrome from single digit factors",
6
+ "property": "smallest",
7
+ "input_min": 1,
8
+ "input_max": 9,
9
+ "expected": {
10
+ "value": 1,
11
+ "factors": [
12
+ [1, 1]
13
+ ]
14
+ }
15
+ },
16
+ {
17
+ "description": "finds the largest palindrome from single digit factors",
18
+ "property": "largest",
19
+ "input_min": 1,
20
+ "input_max": 9,
21
+ "expected": {
22
+ "value": 9,
23
+ "factors": [
24
+ [1, 9],
25
+ [3, 3]
26
+ ]
27
+ }
28
+ },
29
+ {
30
+ "description": "find the smallest palindrome from double digit factors",
31
+ "property": "smallest",
32
+ "input_min": 10,
33
+ "input_max": 99,
34
+ "expected": {
35
+ "value": 121,
36
+ "factors": [
37
+ [11, 11]
38
+ ]
39
+ }
40
+ },
41
+ {
42
+ "description": "find the largest palindrome from double digit factors",
43
+ "property": "largest",
44
+ "input_min": 10,
45
+ "input_max": 99,
46
+ "expected": {
47
+ "value": 9009,
48
+ "factors": [
49
+ [91, 99]
50
+ ]
51
+ }
52
+ },
53
+ {
54
+ "description": "find smallest palindrome from triple digit factors",
55
+ "property": "smallest",
56
+ "input_min": 100,
57
+ "input_max": 999,
58
+ "expected": {
59
+ "value": 10201,
60
+ "factors": [
61
+ [101, 101]
62
+ ]
63
+ }
64
+ },
65
+ {
66
+ "description": "find the largest palindrome from triple digit factors",
67
+ "property": "largest",
68
+ "input_min": 100,
69
+ "input_max": 999,
70
+ "expected": {
71
+ "value": 906609,
72
+ "factors": [
73
+ [913, 993]
74
+ ]
75
+ }
76
+ },
77
+ {
78
+ "description": "find smallest palindrome from four digit factors",
79
+ "property": "smallest",
80
+ "input_min": 1000,
81
+ "input_max": 9999,
82
+ "expected": {
83
+ "value": 1002001,
84
+ "factors": [
85
+ [1001, 1001]
86
+ ]
87
+ }
88
+ },
89
+ {
90
+ "description": "find the largest palindrome from four digit factors",
91
+ "property": "largest",
92
+ "input_min": 1000,
93
+ "input_max": 9999,
94
+ "expected": {
95
+ "value": 99000099,
96
+ "factors": [
97
+ [9901, 9999]
98
+ ]
99
+ }
100
+ },
101
+ {
102
+ "description": "empty result for smallest if no palindrome in the range",
103
+ "property": "smallest",
104
+ "input_min": 1002,
105
+ "input_max": 1003,
106
+ "expected": {
107
+ "error": "no palindrome with factors in the range 1002 to 1003"
108
+ }
109
+ },
110
+ {
111
+ "description": "empty result for largest if no palindrome in the range",
112
+ "property": "largest",
113
+ "input_min": 15,
114
+ "input_max": 15,
115
+ "expected": {
116
+ "error": "no palindrome with factors in the range 15 to 15"
117
+ }
118
+ },
119
+ {
120
+ "description": "error result for smallest if min is more than max",
121
+ "property": "smallest",
122
+ "input_min": 10000,
123
+ "input_max": 1,
124
+ "expected": {
125
+ "error": "invalid input: min is 10000 and max is 1"
126
+ }
127
+ },
128
+ {
129
+ "description": "error result for largest if min is more than max",
130
+ "property": "largest",
131
+ "input_min": 2,
132
+ "input_max": 1,
133
+ "expected": {
134
+ "error": "invalid input: min is 2 and max is 1"
135
+ }
136
+ }
137
+ ]
138
+ }
@@ -7,91 +7,91 @@ public class BookStoreTest
7
7
  [Fact]
8
8
  public void Only_a_single_book()
9
9
  {
10
- var input = new[] { 1 };
11
- Assert.Equal(8, BookStore.Total(input));
10
+ var basket = new[] { 1 };
11
+ Assert.Equal(8, BookStore.Total(basket));
12
12
  }
13
13
 
14
14
  [Fact(Skip = "Remove to run test")]
15
15
  public void Two_of_the_same_book()
16
16
  {
17
- var input = new[] { 2, 2 };
18
- Assert.Equal(16, BookStore.Total(input));
17
+ var basket = new[] { 2, 2 };
18
+ Assert.Equal(16, BookStore.Total(basket));
19
19
  }
20
20
 
21
21
  [Fact(Skip = "Remove to run test")]
22
22
  public void Empty_basket()
23
23
  {
24
- var input = new int[0];
25
- Assert.Equal(0, BookStore.Total(input));
24
+ var basket = new int[0];
25
+ Assert.Equal(0, BookStore.Total(basket));
26
26
  }
27
27
 
28
28
  [Fact(Skip = "Remove to run test")]
29
29
  public void Two_different_books()
30
30
  {
31
- var input = new[] { 1, 2 };
32
- Assert.Equal(15.2, BookStore.Total(input));
31
+ var basket = new[] { 1, 2 };
32
+ Assert.Equal(15.2, BookStore.Total(basket));
33
33
  }
34
34
 
35
35
  [Fact(Skip = "Remove to run test")]
36
36
  public void Three_different_books()
37
37
  {
38
- var input = new[] { 1, 2, 3 };
39
- Assert.Equal(21.6, BookStore.Total(input));
38
+ var basket = new[] { 1, 2, 3 };
39
+ Assert.Equal(21.6, BookStore.Total(basket));
40
40
  }
41
41
 
42
42
  [Fact(Skip = "Remove to run test")]
43
43
  public void Four_different_books()
44
44
  {
45
- var input = new[] { 1, 2, 3, 4 };
46
- Assert.Equal(25.6, BookStore.Total(input));
45
+ var basket = new[] { 1, 2, 3, 4 };
46
+ Assert.Equal(25.6, BookStore.Total(basket));
47
47
  }
48
48
 
49
49
  [Fact(Skip = "Remove to run test")]
50
50
  public void Five_different_books()
51
51
  {
52
- var input = new[] { 1, 2, 3, 4, 5 };
53
- Assert.Equal(30, BookStore.Total(input));
52
+ var basket = new[] { 1, 2, 3, 4, 5 };
53
+ Assert.Equal(30, BookStore.Total(basket));
54
54
  }
55
55
 
56
56
  [Fact(Skip = "Remove to run test")]
57
57
  public void Two_groups_of_four_is_cheaper_than_group_of_five_plus_group_of_three()
58
58
  {
59
- var input = new[] { 1, 1, 2, 2, 3, 3, 4, 5 };
60
- Assert.Equal(51.2, BookStore.Total(input));
59
+ var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 5 };
60
+ Assert.Equal(51.2, BookStore.Total(basket));
61
61
  }
62
62
 
63
63
  [Fact(Skip = "Remove to run test")]
64
64
  public void Group_of_four_plus_group_of_two_is_cheaper_than_two_groups_of_three()
65
65
  {
66
- var input = new[] { 1, 1, 2, 2, 3, 4 };
67
- Assert.Equal(40.8, BookStore.Total(input));
66
+ var basket = new[] { 1, 1, 2, 2, 3, 4 };
67
+ Assert.Equal(40.8, BookStore.Total(basket));
68
68
  }
69
69
 
70
70
  [Fact(Skip = "Remove to run test")]
71
71
  public void Two_each_of_first_4_books_and_1_copy_each_of_rest()
72
72
  {
73
- var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5 };
74
- Assert.Equal(55.6, BookStore.Total(input));
73
+ var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5 };
74
+ Assert.Equal(55.6, BookStore.Total(basket));
75
75
  }
76
76
 
77
77
  [Fact(Skip = "Remove to run test")]
78
78
  public void Two_copies_of_each_book()
79
79
  {
80
- var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
81
- Assert.Equal(60, BookStore.Total(input));
80
+ var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
81
+ Assert.Equal(60, BookStore.Total(basket));
82
82
  }
83
83
 
84
84
  [Fact(Skip = "Remove to run test")]
85
85
  public void Three_copies_of_first_book_and_2_each_of_remaining()
86
86
  {
87
- var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1 };
88
- Assert.Equal(68, BookStore.Total(input));
87
+ var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1 };
88
+ Assert.Equal(68, BookStore.Total(basket));
89
89
  }
90
90
 
91
91
  [Fact(Skip = "Remove to run test")]
92
92
  public void Three_each_of_first_2_books_and_2_each_of_remaining_books()
93
93
  {
94
- var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2 };
95
- Assert.Equal(75.2, BookStore.Total(input));
94
+ var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2 };
95
+ Assert.Equal(75.2, BookStore.Total(basket));
96
96
  }
97
97
  }
@@ -52,8 +52,8 @@ public class ComplexNumbersTest
52
52
  {
53
53
  var sut = new ComplexNumber(0, 1);
54
54
  var expected = new ComplexNumber(-1, 0);
55
- Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(0, 1)).Real(), 15);
56
- Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(0, 1)).Imaginary(), 15);
55
+ Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(0, 1)).Real(), precision: 15);
56
+ Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(0, 1)).Imaginary(), precision: 15);
57
57
  }
58
58
 
59
59
  [Fact(Skip = "Remove to run test")]
@@ -61,8 +61,8 @@ public class ComplexNumbersTest
61
61
  {
62
62
  var sut = new ComplexNumber(1, 0);
63
63
  var expected = new ComplexNumber(3, 0);
64
- Assert.Equal(expected.Real(), sut.Add(new ComplexNumber(2, 0)).Real(), 15);
65
- Assert.Equal(expected.Imaginary(), sut.Add(new ComplexNumber(2, 0)).Imaginary(), 15);
64
+ Assert.Equal(expected.Real(), sut.Add(new ComplexNumber(2, 0)).Real(), precision: 15);
65
+ Assert.Equal(expected.Imaginary(), sut.Add(new ComplexNumber(2, 0)).Imaginary(), precision: 15);
66
66
  }
67
67
 
68
68
  [Fact(Skip = "Remove to run test")]
@@ -70,8 +70,8 @@ public class ComplexNumbersTest
70
70
  {
71
71
  var sut = new ComplexNumber(0, 1);
72
72
  var expected = new ComplexNumber(0, 3);
73
- Assert.Equal(expected.Real(), sut.Add(new ComplexNumber(0, 2)).Real(), 15);
74
- Assert.Equal(expected.Imaginary(), sut.Add(new ComplexNumber(0, 2)).Imaginary(), 15);
73
+ Assert.Equal(expected.Real(), sut.Add(new ComplexNumber(0, 2)).Real(), precision: 15);
74
+ Assert.Equal(expected.Imaginary(), sut.Add(new ComplexNumber(0, 2)).Imaginary(), precision: 15);
75
75
  }
76
76
 
77
77
  [Fact(Skip = "Remove to run test")]
@@ -79,8 +79,8 @@ public class ComplexNumbersTest
79
79
  {
80
80
  var sut = new ComplexNumber(1, 2);
81
81
  var expected = new ComplexNumber(4, 6);
82
- Assert.Equal(expected.Real(), sut.Add(new ComplexNumber(3, 4)).Real(), 15);
83
- Assert.Equal(expected.Imaginary(), sut.Add(new ComplexNumber(3, 4)).Imaginary(), 15);
82
+ Assert.Equal(expected.Real(), sut.Add(new ComplexNumber(3, 4)).Real(), precision: 15);
83
+ Assert.Equal(expected.Imaginary(), sut.Add(new ComplexNumber(3, 4)).Imaginary(), precision: 15);
84
84
  }
85
85
 
86
86
  [Fact(Skip = "Remove to run test")]
@@ -88,8 +88,8 @@ public class ComplexNumbersTest
88
88
  {
89
89
  var sut = new ComplexNumber(1, 0);
90
90
  var expected = new ComplexNumber(-1, 0);
91
- Assert.Equal(expected.Real(), sut.Sub(new ComplexNumber(2, 0)).Real(), 15);
92
- Assert.Equal(expected.Imaginary(), sut.Sub(new ComplexNumber(2, 0)).Imaginary(), 15);
91
+ Assert.Equal(expected.Real(), sut.Sub(new ComplexNumber(2, 0)).Real(), precision: 15);
92
+ Assert.Equal(expected.Imaginary(), sut.Sub(new ComplexNumber(2, 0)).Imaginary(), precision: 15);
93
93
  }
94
94
 
95
95
  [Fact(Skip = "Remove to run test")]
@@ -97,8 +97,8 @@ public class ComplexNumbersTest
97
97
  {
98
98
  var sut = new ComplexNumber(0, 1);
99
99
  var expected = new ComplexNumber(0, -1);
100
- Assert.Equal(expected.Real(), sut.Sub(new ComplexNumber(0, 2)).Real(), 15);
101
- Assert.Equal(expected.Imaginary(), sut.Sub(new ComplexNumber(0, 2)).Imaginary(), 15);
100
+ Assert.Equal(expected.Real(), sut.Sub(new ComplexNumber(0, 2)).Real(), precision: 15);
101
+ Assert.Equal(expected.Imaginary(), sut.Sub(new ComplexNumber(0, 2)).Imaginary(), precision: 15);
102
102
  }
103
103
 
104
104
  [Fact(Skip = "Remove to run test")]
@@ -106,8 +106,8 @@ public class ComplexNumbersTest
106
106
  {
107
107
  var sut = new ComplexNumber(1, 2);
108
108
  var expected = new ComplexNumber(-2, -2);
109
- Assert.Equal(expected.Real(), sut.Sub(new ComplexNumber(3, 4)).Real(), 15);
110
- Assert.Equal(expected.Imaginary(), sut.Sub(new ComplexNumber(3, 4)).Imaginary(), 15);
109
+ Assert.Equal(expected.Real(), sut.Sub(new ComplexNumber(3, 4)).Real(), precision: 15);
110
+ Assert.Equal(expected.Imaginary(), sut.Sub(new ComplexNumber(3, 4)).Imaginary(), precision: 15);
111
111
  }
112
112
 
113
113
  [Fact(Skip = "Remove to run test")]
@@ -115,8 +115,8 @@ public class ComplexNumbersTest
115
115
  {
116
116
  var sut = new ComplexNumber(1, 0);
117
117
  var expected = new ComplexNumber(2, 0);
118
- Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(2, 0)).Real(), 15);
119
- Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(2, 0)).Imaginary(), 15);
118
+ Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(2, 0)).Real(), precision: 15);
119
+ Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(2, 0)).Imaginary(), precision: 15);
120
120
  }
121
121
 
122
122
  [Fact(Skip = "Remove to run test")]
@@ -124,8 +124,8 @@ public class ComplexNumbersTest
124
124
  {
125
125
  var sut = new ComplexNumber(0, 1);
126
126
  var expected = new ComplexNumber(-2, 0);
127
- Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(0, 2)).Real(), 15);
128
- Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(0, 2)).Imaginary(), 15);
127
+ Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(0, 2)).Real(), precision: 15);
128
+ Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(0, 2)).Imaginary(), precision: 15);
129
129
  }
130
130
 
131
131
  [Fact(Skip = "Remove to run test")]
@@ -133,8 +133,8 @@ public class ComplexNumbersTest
133
133
  {
134
134
  var sut = new ComplexNumber(1, 2);
135
135
  var expected = new ComplexNumber(-5, 10);
136
- Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(3, 4)).Real(), 15);
137
- Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(3, 4)).Imaginary(), 15);
136
+ Assert.Equal(expected.Real(), sut.Mul(new ComplexNumber(3, 4)).Real(), precision: 15);
137
+ Assert.Equal(expected.Imaginary(), sut.Mul(new ComplexNumber(3, 4)).Imaginary(), precision: 15);
138
138
  }
139
139
 
140
140
  [Fact(Skip = "Remove to run test")]
@@ -142,8 +142,8 @@ public class ComplexNumbersTest
142
142
  {
143
143
  var sut = new ComplexNumber(1, 0);
144
144
  var expected = new ComplexNumber(0.5, 0);
145
- Assert.Equal(expected.Real(), sut.Div(new ComplexNumber(2, 0)).Real(), 15);
146
- Assert.Equal(expected.Imaginary(), sut.Div(new ComplexNumber(2, 0)).Imaginary(), 15);
145
+ Assert.Equal(expected.Real(), sut.Div(new ComplexNumber(2, 0)).Real(), precision: 15);
146
+ Assert.Equal(expected.Imaginary(), sut.Div(new ComplexNumber(2, 0)).Imaginary(), precision: 15);
147
147
  }
148
148
 
149
149
  [Fact(Skip = "Remove to run test")]
@@ -151,8 +151,8 @@ public class ComplexNumbersTest
151
151
  {
152
152
  var sut = new ComplexNumber(0, 1);
153
153
  var expected = new ComplexNumber(0.5, 0);
154
- Assert.Equal(expected.Real(), sut.Div(new ComplexNumber(0, 2)).Real(), 15);
155
- Assert.Equal(expected.Imaginary(), sut.Div(new ComplexNumber(0, 2)).Imaginary(), 15);
154
+ Assert.Equal(expected.Real(), sut.Div(new ComplexNumber(0, 2)).Real(), precision: 15);
155
+ Assert.Equal(expected.Imaginary(), sut.Div(new ComplexNumber(0, 2)).Imaginary(), precision: 15);
156
156
  }
157
157
 
158
158
  [Fact(Skip = "Remove to run test")]
@@ -160,8 +160,8 @@ public class ComplexNumbersTest
160
160
  {
161
161
  var sut = new ComplexNumber(1, 2);
162
162
  var expected = new ComplexNumber(0.44, 0.08);
163
- Assert.Equal(expected.Real(), sut.Div(new ComplexNumber(3, 4)).Real(), 15);
164
- Assert.Equal(expected.Imaginary(), sut.Div(new ComplexNumber(3, 4)).Imaginary(), 15);
163
+ Assert.Equal(expected.Real(), sut.Div(new ComplexNumber(3, 4)).Real(), precision: 15);
164
+ Assert.Equal(expected.Imaginary(), sut.Div(new ComplexNumber(3, 4)).Imaginary(), precision: 15);
165
165
  }
166
166
 
167
167
  [Fact(Skip = "Remove to run test")]
@@ -204,8 +204,8 @@ public class ComplexNumbersTest
204
204
  {
205
205
  var sut = new ComplexNumber(5, 0);
206
206
  var expected = new ComplexNumber(5, 0);
207
- Assert.Equal(expected.Real(), sut.Conjugate().Real(), 15);
208
- Assert.Equal(expected.Imaginary(), sut.Conjugate().Imaginary(), 15);
207
+ Assert.Equal(expected.Real(), sut.Conjugate().Real(), precision: 15);
208
+ Assert.Equal(expected.Imaginary(), sut.Conjugate().Imaginary(), precision: 15);
209
209
  }
210
210
 
211
211
  [Fact(Skip = "Remove to run test")]
@@ -213,8 +213,8 @@ public class ComplexNumbersTest
213
213
  {
214
214
  var sut = new ComplexNumber(0, 5);
215
215
  var expected = new ComplexNumber(0, -5);
216
- Assert.Equal(expected.Real(), sut.Conjugate().Real(), 15);
217
- Assert.Equal(expected.Imaginary(), sut.Conjugate().Imaginary(), 15);
216
+ Assert.Equal(expected.Real(), sut.Conjugate().Real(), precision: 15);
217
+ Assert.Equal(expected.Imaginary(), sut.Conjugate().Imaginary(), precision: 15);
218
218
  }
219
219
 
220
220
  [Fact(Skip = "Remove to run test")]
@@ -222,8 +222,8 @@ public class ComplexNumbersTest
222
222
  {
223
223
  var sut = new ComplexNumber(1, 1);
224
224
  var expected = new ComplexNumber(1, -1);
225
- Assert.Equal(expected.Real(), sut.Conjugate().Real(), 15);
226
- Assert.Equal(expected.Imaginary(), sut.Conjugate().Imaginary(), 15);
225
+ Assert.Equal(expected.Real(), sut.Conjugate().Real(), precision: 15);
226
+ Assert.Equal(expected.Imaginary(), sut.Conjugate().Imaginary(), precision: 15);
227
227
  }
228
228
 
229
229
  [Fact(Skip = "Remove to run test")]
@@ -231,8 +231,8 @@ public class ComplexNumbersTest
231
231
  {
232
232
  var sut = new ComplexNumber(0, Math.PI);
233
233
  var expected = new ComplexNumber(-1, 0);
234
- Assert.Equal(expected.Real(), sut.Exp().Real(), 15);
235
- Assert.Equal(expected.Imaginary(), sut.Exp().Imaginary(), 15);
234
+ Assert.Equal(expected.Real(), sut.Exp().Real(), precision: 15);
235
+ Assert.Equal(expected.Imaginary(), sut.Exp().Imaginary(), precision: 15);
236
236
  }
237
237
 
238
238
  [Fact(Skip = "Remove to run test")]
@@ -240,8 +240,8 @@ public class ComplexNumbersTest
240
240
  {
241
241
  var sut = new ComplexNumber(0, 0);
242
242
  var expected = new ComplexNumber(1, 0);
243
- Assert.Equal(expected.Real(), sut.Exp().Real(), 15);
244
- Assert.Equal(expected.Imaginary(), sut.Exp().Imaginary(), 15);
243
+ Assert.Equal(expected.Real(), sut.Exp().Real(), precision: 15);
244
+ Assert.Equal(expected.Imaginary(), sut.Exp().Imaginary(), precision: 15);
245
245
  }
246
246
 
247
247
  [Fact(Skip = "Remove to run test")]
@@ -249,7 +249,7 @@ public class ComplexNumbersTest
249
249
  {
250
250
  var sut = new ComplexNumber(1, 0);
251
251
  var expected = new ComplexNumber(Math.E, 0);
252
- Assert.Equal(expected.Real(), sut.Exp().Real(), 15);
253
- Assert.Equal(expected.Imaginary(), sut.Exp().Imaginary(), 15);
252
+ Assert.Equal(expected.Real(), sut.Exp().Real(), precision: 15);
253
+ Assert.Equal(expected.Imaginary(), sut.Exp().Imaginary(), precision: 15);
254
254
  }
255
255
  }
@@ -9,8 +9,6 @@ namespace Generators.Exercises
9
9
  {
10
10
  foreach (var canonicalDataCase in canonicalData.Cases)
11
11
  {
12
- canonicalDataCase.Input["input_digits"] = canonicalDataCase.Input["input_digits"].ConvertToEnumerable<int>();
13
-
14
12
  canonicalDataCase.ExceptionThrown = canonicalDataCase.Expected is null ? typeof(ArgumentException) : null;
15
13
  canonicalDataCase.UseVariablesForInput = true;
16
14
  canonicalDataCase.UseVariableForExpected = true;
@@ -1,8 +1,5 @@
1
- using System.Collections.Generic;
2
- using System.Linq;
3
- using Generators.Input;
1
+ using Generators.Input;
4
2
  using Generators.Output;
5
- using Newtonsoft.Json.Linq;
6
3
 
7
4
  namespace Generators.Exercises
8
5
  {
@@ -13,19 +10,11 @@ namespace Generators.Exercises
13
10
  foreach (var canonicalDataCase in canonicalData.Cases)
14
11
  {
15
12
  if (canonicalDataCase.Property == "allergicTo")
16
- {
17
13
  canonicalDataCase.Property = "IsAllergicTo";
18
- }
19
14
  else if (canonicalDataCase.Property == "list")
20
- {
21
- canonicalDataCase.Expected = canonicalDataCase.Expected.ConvertToEnumerable<string>();
22
15
  canonicalDataCase.UseVariableForExpected = true;
23
- }
24
16
 
25
- canonicalDataCase.ConstructorInput = new Dictionary<string, object>
26
- {
27
- ["score"] = canonicalDataCase.Properties["score"]
28
- };
17
+ canonicalDataCase.SetConstructorInputParameters("score");
29
18
  }
30
19
  }
31
20
 
@@ -41,17 +30,10 @@ namespace Generators.Exercises
41
30
  {
42
31
  const string template =
43
32
  @"{%- for allergy in Allergies -%}
44
- Assert.{% if allergy.Result %}True{% else %}False{% endif %}(sut.IsAllergicTo(""{{ allergy.Substance }}""));
33
+ Assert.{% if allergy.result %}True{% else %}False{% endif %}(sut.IsAllergicTo(""{{ allergy.substance }}""));
45
34
  {%- endfor -%}";
46
-
47
- var templateParameters = new
48
- {
49
- Allergies = ((JArray) testMethodBody.CanonicalDataCase.Expected)
50
- .Children<JObject>()
51
- .Select(x => new {Result = x["result"].Value<bool>(), Substance = x["substance"].Value<string>()})
52
- .ToArray()
53
- };
54
-
35
+
36
+ var templateParameters = new { Allergies = testMethodBody.CanonicalDataCase.Expected };
55
37
  return TemplateRenderer.RenderInline(template, templateParameters);
56
38
  }
57
39
  }
@@ -1,7 +1,7 @@
1
1
  using System;
2
2
  using System.Collections.Generic;
3
+ using System.Linq;
3
4
  using Generators.Input;
4
- using Newtonsoft.Json.Linq;
5
5
 
6
6
  namespace Generators.Exercises
7
7
  {
@@ -17,16 +17,13 @@ namespace Generators.Exercises
17
17
  if (canonicalDataCase.Expected == null)
18
18
  canonicalDataCase.ExceptionThrown = typeof(ArgumentException);
19
19
  else
20
- canonicalDataCase.Expected = ((JObject)canonicalDataCase.Expected).ToObject<Dictionary<char, int>>();
20
+ canonicalDataCase.Expected = ConvertExpected(canonicalDataCase);
21
21
  }
22
22
  }
23
23
 
24
- protected override HashSet<string> AddAdditionalNamespaces()
25
- {
26
- return new HashSet<string>()
27
- {
28
- typeof(Dictionary<char, int>).Namespace
29
- };
30
- }
24
+ private static dynamic ConvertExpected(CanonicalDataCase canonicalDataCase)
25
+ => ((Dictionary<string, object>)canonicalDataCase.Expected).ToDictionary(kv => kv.Key[0], kv => int.Parse(kv.Value.ToString()));
26
+
27
+ protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string> { typeof(Dictionary<char, int>).Namespace };
31
28
  }
32
29
  }
@@ -1,4 +1,3 @@
1
- using System.Collections.Generic;
2
1
  using Generators.Input;
3
2
 
4
3
  namespace Generators.Exercises
@@ -9,15 +8,9 @@ namespace Generators.Exercises
9
8
  {
10
9
  foreach (var canonicalDataCase in canonicalData.Cases)
11
10
  {
12
- canonicalDataCase.ConstructorInput = new Dictionary<string, object>
13
- {
14
- ["subject"] = canonicalDataCase.Input["subject"]
15
- };
16
- canonicalDataCase.Input["candidates"] = canonicalDataCase.Input["candidates"].ConvertToEnumerable<string>();
17
- canonicalDataCase.Expected = canonicalDataCase.Expected.ConvertToEnumerable<string>();
18
-
19
11
  canonicalDataCase.UseVariablesForInput = true;
20
12
  canonicalDataCase.UseVariableForExpected = true;
13
+ canonicalDataCase.SetConstructorInputParameters("subject");
21
14
  }
22
15
  }
23
16
  }
@@ -1,5 +1,4 @@
1
- using System.Collections.Generic;
2
- using Generators.Input;
1
+ using Generators.Input;
3
2
 
4
3
  namespace Generators.Exercises
5
4
  {
@@ -9,12 +8,8 @@ namespace Generators.Exercises
9
8
  {
10
9
  foreach (var canonicalDataCase in canonicalData.Cases)
11
10
  {
12
- canonicalDataCase.ConstructorInput = new Dictionary<string, object>
13
- {
14
- ["array"] = canonicalDataCase.Input["array"].ConvertToEnumerable<int>()
15
- };
16
-
17
11
  canonicalDataCase.UseVariablesForConstructorParameters = true;
12
+ canonicalDataCase.SetConstructorInputParameters("array");
18
13
  }
19
14
  }
20
15
  }
@@ -1,5 +1,4 @@
1
- using System.Collections.Generic;
2
- using Generators.Input;
1
+ using Generators.Input;
3
2
 
4
3
  namespace Generators.Exercises
5
4
  {
@@ -9,10 +8,7 @@ namespace Generators.Exercises
9
8
  {
10
9
  foreach (var canonicalDataCase in canonicalData.Cases)
11
10
  {
12
- canonicalDataCase.Input = new Dictionary<string, object>
13
- {
14
- ["input"] = canonicalDataCase.Input["basket"].ConvertToEnumerable<int>()
15
- };
11
+ canonicalDataCase.SetInputParameters("basket");
16
12
  canonicalDataCase.UseVariablesForInput = true;
17
13
  }
18
14
  }
@@ -8,7 +8,7 @@ namespace Generators.Exercises
8
8
  {
9
9
  foreach (var canonicalDataCase in canonicalData.Cases)
10
10
  {
11
- canonicalDataCase.Input["input"] = ((string)canonicalDataCase.Input["input"]).Replace("\\", "\\\\");
11
+ canonicalDataCase.Properties["input"] = canonicalDataCase.Properties["input"].Replace("\\", "\\\\");
12
12
  canonicalDataCase.UseVariablesForInput = true;
13
13
  }
14
14
  }
@@ -8,9 +8,7 @@ namespace Generators.Exercises
8
8
  protected override void UpdateCanonicalData(CanonicalData canonicalData)
9
9
  {
10
10
  foreach (var canonicalDataCase in canonicalData.Cases)
11
- {
12
- canonicalDataCase.ExceptionThrown = (long)canonicalDataCase.Input["number"] <= 0 ? typeof(ArgumentException) : null;
13
- }
11
+ canonicalDataCase.ExceptionThrown = canonicalDataCase.Input["number"] <= 0 ? typeof(ArgumentException) : null;
14
12
  }
15
13
  }
16
14
  }