trackler 2.2.1.20 → 2.2.1.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/csharp/config.json +11 -0
  4. data/tracks/csharp/exercises/Exercises.All.sln +15 -1
  5. data/tracks/csharp/exercises/Exercises.Default.sln +120 -106
  6. data/tracks/csharp/exercises/complex-numbers/ComplexNumbers.cs +53 -0
  7. data/tracks/csharp/exercises/complex-numbers/ComplexNumbers.csproj +18 -0
  8. data/tracks/csharp/exercises/complex-numbers/ComplexNumbersTest.cs +255 -0
  9. data/tracks/csharp/exercises/complex-numbers/Example.cs +78 -0
  10. data/tracks/csharp/exercises/grains/Example.cs +8 -1
  11. data/tracks/csharp/exercises/grains/GrainsTest.cs +38 -17
  12. data/tracks/csharp/generators/Exercises/ComplexNumbers.cs +119 -0
  13. data/tracks/csharp/generators/Exercises/Grains.cs +29 -0
  14. data/tracks/csharp/generators/Output/ValueFormatter.cs +2 -0
  15. data/tracks/delphi/exercises/two-fer/utwoferExample.pas +2 -5
  16. data/tracks/ecmascript/exercises/queen-attack/example.js +28 -23
  17. data/tracks/ecmascript/exercises/queen-attack/queen-attack.spec.js +10 -15
  18. data/tracks/java/config.json +1 -0
  19. data/tracks/r/exercises/perfect-numbers/example.R +1 -1
  20. data/tracks/r/exercises/perfect-numbers/perfect-numbers.R +1 -1
  21. data/tracks/r/exercises/perfect-numbers/test_perfect-numbers.R +13 -13
  22. data/tracks/ruby/docs/24pullrequests.md +1 -1
  23. data/tracks/ruby/exercises/hello-world/.meta/generator/test_template.erb +1 -1
  24. data/tracks/ruby/exercises/hello-world/hello_world_test.rb +1 -1
  25. data/tracks/ruby/test/generator/command_line/generator_optparser_test.rb +1 -1
  26. data/tracks/ruby/test/generator/command_line_test.rb +1 -1
  27. data/tracks/ruby/test/generator/files/metadata_files_test.rb +1 -1
  28. data/tracks/rust/exercises/accumulate/README.md +0 -3
  29. data/tracks/rust/exercises/beer-song/src/lib.rs +7 -0
  30. data/tracks/rust/exercises/bob/src/lib.rs +3 -0
  31. data/tracks/rust/exercises/bowling/example.rs +1 -1
  32. data/tracks/rust/exercises/difference-of-squares/src/lib.rs +11 -0
  33. data/tracks/rust/exercises/grade-school/example.rs +1 -1
  34. data/tracks/rust/exercises/leap/src/lib.rs +3 -0
  35. data/tracks/rust/exercises/proverb/src/lib.rs +3 -0
  36. data/tracks/rust/exercises/raindrops/src/lib.rs +3 -0
  37. data/tracks/rust/exercises/sum-of-multiples/src/lib.rs +3 -0
  38. data/tracks/scala/exercises/space-age/example.scala +26 -20
  39. data/tracks/scala/exercises/space-age/src/main/scala/.keep +0 -0
  40. data/tracks/scala/exercises/space-age/src/test/scala/SpaceAgeTest.scala +19 -38
  41. data/tracks/scala/exercises/sublist/src/test/scala/SublistTest.scala +36 -44
  42. data/tracks/scala/testgen/src/main/scala/SpaceAgeTestGenerator.scala +39 -0
  43. data/tracks/scala/testgen/src/main/scala/SublistTestGenerator.scala +38 -0
  44. metadata +11 -3
  45. data/tracks/scala/exercises/space-age/src/main/scala/SpaceAge.scala +0 -10
@@ -0,0 +1,18 @@
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <OutputType>Exe</OutputType>
5
+ <TargetFramework>netcoreapp1.0</TargetFramework>
6
+ </PropertyGroup>
7
+
8
+ <ItemGroup>
9
+ <Compile Remove="Example.cs" />
10
+ </ItemGroup>
11
+
12
+ <ItemGroup>
13
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
14
+ <PackageReference Include="xunit" Version="2.2.0" />
15
+ <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
16
+ </ItemGroup>
17
+
18
+ </Project>
@@ -0,0 +1,255 @@
1
+ // This file was auto-generated based on version 1.0.0 of the canonical data.
2
+
3
+ using Xunit;
4
+ using System;
5
+
6
+ public class ComplexNumbersTest
7
+ {
8
+ [Fact]
9
+ public void Real_part_of_a_purely_real_number()
10
+ {
11
+ var sut = new ComplexNumber(1, 0);
12
+ Assert.Equal(1, sut.Real());
13
+ }
14
+
15
+ [Fact(Skip = "Remove to run test")]
16
+ public void Real_part_of_a_purely_imaginary_number()
17
+ {
18
+ var sut = new ComplexNumber(0, 1);
19
+ Assert.Equal(0, sut.Real());
20
+ }
21
+
22
+ [Fact(Skip = "Remove to run test")]
23
+ public void Real_part_of_a_number_with_real_and_imaginary_part()
24
+ {
25
+ var sut = new ComplexNumber(1, 2);
26
+ Assert.Equal(1, sut.Real());
27
+ }
28
+
29
+ [Fact(Skip = "Remove to run test")]
30
+ public void Imaginary_part_of_a_purely_real_number()
31
+ {
32
+ var sut = new ComplexNumber(1, 0);
33
+ Assert.Equal(0, sut.Imaginary());
34
+ }
35
+
36
+ [Fact(Skip = "Remove to run test")]
37
+ public void Imaginary_part_of_a_purely_imaginary_number()
38
+ {
39
+ var sut = new ComplexNumber(0, 1);
40
+ Assert.Equal(1, sut.Imaginary());
41
+ }
42
+
43
+ [Fact(Skip = "Remove to run test")]
44
+ public void Imaginary_part_of_a_number_with_real_and_imaginary_part()
45
+ {
46
+ var sut = new ComplexNumber(1, 2);
47
+ Assert.Equal(2, sut.Imaginary());
48
+ }
49
+
50
+ [Fact(Skip = "Remove to run test")]
51
+ public void Imaginary_unit()
52
+ {
53
+ var sut = new ComplexNumber(0, 1);
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);
57
+ }
58
+
59
+ [Fact(Skip = "Remove to run test")]
60
+ public void Add_purely_real_numbers()
61
+ {
62
+ var sut = new ComplexNumber(1, 0);
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);
66
+ }
67
+
68
+ [Fact(Skip = "Remove to run test")]
69
+ public void Add_purely_imaginary_numbers()
70
+ {
71
+ var sut = new ComplexNumber(0, 1);
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);
75
+ }
76
+
77
+ [Fact(Skip = "Remove to run test")]
78
+ public void Add_numbers_with_real_and_imaginary_part()
79
+ {
80
+ var sut = new ComplexNumber(1, 2);
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);
84
+ }
85
+
86
+ [Fact(Skip = "Remove to run test")]
87
+ public void Subtract_purely_real_numbers()
88
+ {
89
+ var sut = new ComplexNumber(1, 0);
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);
93
+ }
94
+
95
+ [Fact(Skip = "Remove to run test")]
96
+ public void Subtract_purely_imaginary_numbers()
97
+ {
98
+ var sut = new ComplexNumber(0, 1);
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);
102
+ }
103
+
104
+ [Fact(Skip = "Remove to run test")]
105
+ public void Subtract_numbers_with_real_and_imaginary_part()
106
+ {
107
+ var sut = new ComplexNumber(1, 2);
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);
111
+ }
112
+
113
+ [Fact(Skip = "Remove to run test")]
114
+ public void Multiply_purely_real_numbers()
115
+ {
116
+ var sut = new ComplexNumber(1, 0);
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);
120
+ }
121
+
122
+ [Fact(Skip = "Remove to run test")]
123
+ public void Multiply_purely_imaginary_numbers()
124
+ {
125
+ var sut = new ComplexNumber(0, 1);
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);
129
+ }
130
+
131
+ [Fact(Skip = "Remove to run test")]
132
+ public void Multiply_numbers_with_real_and_imaginary_part()
133
+ {
134
+ var sut = new ComplexNumber(1, 2);
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);
138
+ }
139
+
140
+ [Fact(Skip = "Remove to run test")]
141
+ public void Divide_purely_real_numbers()
142
+ {
143
+ var sut = new ComplexNumber(1, 0);
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);
147
+ }
148
+
149
+ [Fact(Skip = "Remove to run test")]
150
+ public void Divide_purely_imaginary_numbers()
151
+ {
152
+ var sut = new ComplexNumber(0, 1);
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);
156
+ }
157
+
158
+ [Fact(Skip = "Remove to run test")]
159
+ public void Divide_numbers_with_real_and_imaginary_part()
160
+ {
161
+ var sut = new ComplexNumber(1, 2);
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);
165
+ }
166
+
167
+ [Fact(Skip = "Remove to run test")]
168
+ public void Absolute_value_of_a_positive_purely_real_number()
169
+ {
170
+ var sut = new ComplexNumber(5, 0);
171
+ Assert.Equal(5, sut.Abs());
172
+ }
173
+
174
+ [Fact(Skip = "Remove to run test")]
175
+ public void Absolute_value_of_a_negative_purely_real_number()
176
+ {
177
+ var sut = new ComplexNumber(-5, 0);
178
+ Assert.Equal(5, sut.Abs());
179
+ }
180
+
181
+ [Fact(Skip = "Remove to run test")]
182
+ public void Absolute_value_of_a_purely_imaginary_number_with_positive_imaginary_part()
183
+ {
184
+ var sut = new ComplexNumber(0, 5);
185
+ Assert.Equal(5, sut.Abs());
186
+ }
187
+
188
+ [Fact(Skip = "Remove to run test")]
189
+ public void Absolute_value_of_a_purely_imaginary_number_with_negative_imaginary_part()
190
+ {
191
+ var sut = new ComplexNumber(0, -5);
192
+ Assert.Equal(5, sut.Abs());
193
+ }
194
+
195
+ [Fact(Skip = "Remove to run test")]
196
+ public void Absolute_value_of_a_number_with_real_and_imaginary_part()
197
+ {
198
+ var sut = new ComplexNumber(3, 4);
199
+ Assert.Equal(5, sut.Abs());
200
+ }
201
+
202
+ [Fact(Skip = "Remove to run test")]
203
+ public void Conjugate_a_purely_real_number()
204
+ {
205
+ var sut = new ComplexNumber(5, 0);
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);
209
+ }
210
+
211
+ [Fact(Skip = "Remove to run test")]
212
+ public void Conjugate_a_purely_imaginary_number()
213
+ {
214
+ var sut = new ComplexNumber(0, 5);
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);
218
+ }
219
+
220
+ [Fact(Skip = "Remove to run test")]
221
+ public void Conjugate_a_number_with_real_and_imaginary_part()
222
+ {
223
+ var sut = new ComplexNumber(1, 1);
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);
227
+ }
228
+
229
+ [Fact(Skip = "Remove to run test")]
230
+ public void Eulers_identity_formula()
231
+ {
232
+ var sut = new ComplexNumber(0, Math.PI);
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);
236
+ }
237
+
238
+ [Fact(Skip = "Remove to run test")]
239
+ public void Exponential_of_0()
240
+ {
241
+ var sut = new ComplexNumber(0, 0);
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);
245
+ }
246
+
247
+ [Fact(Skip = "Remove to run test")]
248
+ public void Exponential_of_a_purely_real_number()
249
+ {
250
+ var sut = new ComplexNumber(1, 0);
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);
254
+ }
255
+ }
@@ -0,0 +1,78 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+
4
+ [DebuggerDisplay("{_real} + {_imaginary}i")]
5
+ public struct ComplexNumber
6
+ {
7
+ private readonly double _real;
8
+ private readonly double _imaginary;
9
+
10
+ public ComplexNumber(double real, double imaginary)
11
+ {
12
+ _real = real;
13
+ _imaginary = imaginary;
14
+ }
15
+
16
+ public double Real()
17
+ {
18
+ return _real;
19
+ }
20
+
21
+ public double Imaginary()
22
+ {
23
+ return _imaginary;
24
+ }
25
+
26
+ public ComplexNumber Mul(ComplexNumber other)
27
+ {
28
+ return new ComplexNumber(
29
+ _real * other._real - _imaginary * other._imaginary,
30
+ _imaginary * other._real + _real * other._imaginary);
31
+ }
32
+
33
+ public ComplexNumber Add(ComplexNumber other)
34
+ {
35
+ return new ComplexNumber(
36
+ _real + other._real,
37
+ _imaginary + other._imaginary);
38
+ }
39
+
40
+ public ComplexNumber Sub(ComplexNumber other)
41
+ {
42
+ return new ComplexNumber(
43
+ _real - other._real,
44
+ _imaginary - other._imaginary);
45
+ }
46
+
47
+ public ComplexNumber Div(ComplexNumber other)
48
+ {
49
+ var denominator = other._real * other._real + other._imaginary * other._imaginary;
50
+ var real = (_real * other._real + _imaginary * other._imaginary) / denominator;
51
+ var imaginary = (_imaginary * other._real - _real * _real * other._imaginary) / denominator;
52
+
53
+ return new ComplexNumber(real, imaginary);
54
+ }
55
+
56
+ public double Abs()
57
+ {
58
+ return Math.Sqrt(_real * _real + _imaginary * _imaginary);
59
+ }
60
+
61
+ public ComplexNumber Conjugate()
62
+ {
63
+ return new ComplexNumber(
64
+ _real,
65
+ -1 * _imaginary);
66
+ }
67
+
68
+ public ComplexNumber Exp()
69
+ {
70
+ var real = Math.Cos(_imaginary);
71
+ var imaginary = Math.Sin(_imaginary);
72
+ var factor = Math.Exp(_real);
73
+
74
+ return new ComplexNumber(
75
+ real * factor,
76
+ imaginary * factor);
77
+ }
78
+ }
@@ -1,7 +1,14 @@
1
- public static class Grains
1
+ using System;
2
+
3
+ public static class Grains
2
4
  {
3
5
  public static ulong Square(int n)
4
6
  {
7
+ if (n <= 0 || n > 64)
8
+ {
9
+ throw new ArgumentOutOfRangeException(nameof(n));
10
+ }
11
+
5
12
  return n == 1
6
13
  ? 1
7
14
  : 2 * Square(n - 1);
@@ -1,52 +1,73 @@
1
- using Xunit;
1
+ // This file was auto-generated based on version 1.0.0 of the canonical data.
2
+
3
+ using Xunit;
4
+ using System;
2
5
 
3
6
  public class GrainsTest
4
7
  {
5
8
  [Fact]
6
- public void Test_square_1()
9
+ public void Returns_the_total_number_of_grains_on_the_board()
10
+ {
11
+ Assert.Equal(18446744073709551615UL, Grains.Total());
12
+ }
13
+
14
+ [Fact(Skip = "Remove to run test")]
15
+ public void Number_1()
16
+ {
17
+ Assert.Equal(1UL, Grains.Square(1));
18
+ }
19
+
20
+ [Fact(Skip = "Remove to run test")]
21
+ public void Number_2()
22
+ {
23
+ Assert.Equal(2UL, Grains.Square(2));
24
+ }
25
+
26
+ [Fact(Skip = "Remove to run test")]
27
+ public void Number_3()
7
28
  {
8
- Assert.Equal(1ul, Grains.Square(1));
29
+ Assert.Equal(4UL, Grains.Square(3));
9
30
  }
10
31
 
11
32
  [Fact(Skip = "Remove to run test")]
12
- public void Test_square_2()
33
+ public void Number_4()
13
34
  {
14
- Assert.Equal(2ul, Grains.Square(2));
35
+ Assert.Equal(8UL, Grains.Square(4));
15
36
  }
16
37
 
17
38
  [Fact(Skip = "Remove to run test")]
18
- public void Test_square_3()
39
+ public void Number_16()
19
40
  {
20
- Assert.Equal(4ul, Grains.Square(3));
41
+ Assert.Equal(32768UL, Grains.Square(16));
21
42
  }
22
43
 
23
44
  [Fact(Skip = "Remove to run test")]
24
- public void Test_square_4()
45
+ public void Number_32()
25
46
  {
26
- Assert.Equal(8ul, Grains.Square(4));
47
+ Assert.Equal(2147483648UL, Grains.Square(32));
27
48
  }
28
49
 
29
50
  [Fact(Skip = "Remove to run test")]
30
- public void Test_square_16()
51
+ public void Number_64()
31
52
  {
32
- Assert.Equal(32768ul, Grains.Square(16));
53
+ Assert.Equal(9223372036854775808UL, Grains.Square(64));
33
54
  }
34
55
 
35
56
  [Fact(Skip = "Remove to run test")]
36
- public void Test_square_32()
57
+ public void Square_0_raises_an_exception()
37
58
  {
38
- Assert.Equal(2147483648ul, Grains.Square(32));
59
+ Assert.Throws<ArgumentOutOfRangeException>(() => Grains.Square(0));
39
60
  }
40
61
 
41
62
  [Fact(Skip = "Remove to run test")]
42
- public void Test_square_64()
63
+ public void Negative_square_raises_an_exception()
43
64
  {
44
- Assert.Equal(9223372036854775808ul, Grains.Square(64));
65
+ Assert.Throws<ArgumentOutOfRangeException>(() => Grains.Square(-1));
45
66
  }
46
67
 
47
68
  [Fact(Skip = "Remove to run test")]
48
- public void Test_total_grains()
69
+ public void Square_greater_than_64_raises_an_exception()
49
70
  {
50
- Assert.Equal(18446744073709551615ul, Grains.Total());
71
+ Assert.Throws<ArgumentOutOfRangeException>(() => Grains.Square(65));
51
72
  }
52
73
  }