trackler 2.2.1.12 → 2.2.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/space-age/description.md +2 -1
  4. data/problem-specifications/exercises/two-fer/canonical-data.json +4 -4
  5. data/tracks/csharp/.gitignore +2 -1
  6. data/tracks/csharp/config/maintainers.json +3 -3
  7. data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.cs +1 -1
  8. data/tracks/csharp/exercises/collatz-conjecture/CollatzConjectureTest.cs +8 -8
  9. data/tracks/csharp/exercises/collatz-conjecture/Example.cs +6 -6
  10. data/tracks/csharp/exercises/gigasecond/Example.cs +1 -1
  11. data/tracks/csharp/exercises/gigasecond/Gigasecond.cs +1 -1
  12. data/tracks/csharp/exercises/gigasecond/GigasecondTest.cs +21 -10
  13. data/tracks/csharp/exercises/hamming/Example.cs +6 -1
  14. data/tracks/csharp/exercises/hamming/Hamming.cs +1 -1
  15. data/tracks/csharp/exercises/hamming/HammingTest.cs +69 -12
  16. data/tracks/csharp/exercises/pangram/PangramTest.cs +15 -20
  17. data/tracks/csharp/exercises/phone-number/Example.cs +15 -42
  18. data/tracks/csharp/exercises/phone-number/PhoneNumber.cs +2 -17
  19. data/tracks/csharp/exercises/phone-number/PhoneNumberTest.cs +57 -20
  20. data/tracks/csharp/exercises/prime-factors/Example.cs +1 -1
  21. data/tracks/csharp/exercises/prime-factors/PrimeFactors.cs +1 -1
  22. data/tracks/csharp/exercises/prime-factors/PrimeFactorsTest.cs +16 -38
  23. data/tracks/csharp/exercises/rail-fence-cipher/RailFenceCipherTest.cs +21 -19
  24. data/tracks/csharp/exercises/rna-transcription/Example.cs +7 -2
  25. data/tracks/csharp/exercises/rna-transcription/RnaTranscription.cs +2 -2
  26. data/tracks/csharp/exercises/rna-transcription/RnaTranscriptionTest.cs +26 -6
  27. data/tracks/csharp/exercises/rotational-cipher/RotationalCipherTest.cs +7 -7
  28. data/tracks/csharp/exercises/run-length-encoding/RunLengthEncodingTest.cs +53 -29
  29. data/tracks/csharp/exercises/scrabble-score/Example.cs +2 -2
  30. data/tracks/csharp/exercises/scrabble-score/ScrabbleScore.cs +1 -1
  31. data/tracks/csharp/exercises/scrabble-score/ScrabbleScoreTest.cs +33 -19
  32. data/tracks/csharp/exercises/secret-handshake/SecretHandshake.cs +0 -1
  33. data/tracks/csharp/exercises/secret-handshake/SecretHandshakeTest.cs +36 -10
  34. data/tracks/csharp/exercises/two-fer/Example.cs +1 -1
  35. data/tracks/csharp/exercises/two-fer/TwoFer.cs +1 -1
  36. data/tracks/csharp/exercises/two-fer/TwoFerTest.cs +19 -19
  37. data/tracks/csharp/generators/.gitignore +1 -1
  38. data/tracks/csharp/generators/Exercise.cs +85 -10
  39. data/tracks/csharp/generators/Exercises/AllYourBase.cs +3 -14
  40. data/tracks/csharp/generators/Exercises/Allergies.cs +21 -18
  41. data/tracks/csharp/generators/Exercises/Alphametics.cs +6 -7
  42. data/tracks/csharp/generators/Exercises/Anagram.cs +4 -4
  43. data/tracks/csharp/generators/Exercises/BeerSong.cs +4 -2
  44. data/tracks/csharp/generators/Exercises/BinarySearch.cs +3 -3
  45. data/tracks/csharp/generators/Exercises/BookStore.cs +3 -3
  46. data/tracks/csharp/generators/Exercises/BracketPush.cs +4 -2
  47. data/tracks/csharp/generators/Exercises/CollatzConjecture.cs +16 -0
  48. data/tracks/csharp/generators/Exercises/ConvertExtensions.cs +12 -0
  49. data/tracks/csharp/generators/Exercises/CryptoSquare.cs +3 -2
  50. data/tracks/csharp/generators/Exercises/FoodChain.cs +3 -3
  51. data/tracks/csharp/generators/Exercises/Gigasecond.cs +38 -0
  52. data/tracks/csharp/generators/Exercises/Hamming.cs +16 -0
  53. data/tracks/csharp/generators/Exercises/Leap.cs +4 -2
  54. data/tracks/csharp/generators/Exercises/Luhn.cs +3 -1
  55. data/tracks/csharp/generators/Exercises/NthPrime.cs +2 -10
  56. data/tracks/csharp/generators/Exercises/Pangram.cs +17 -0
  57. data/tracks/csharp/generators/Exercises/PerfectNumbers.cs +2 -9
  58. data/tracks/csharp/generators/Exercises/PhoneNumber.cs +15 -0
  59. data/tracks/csharp/generators/Exercises/PrimeFactors.cs +6 -0
  60. data/tracks/csharp/generators/Exercises/RailFenceCipher.cs +23 -0
  61. data/tracks/csharp/generators/Exercises/RnaTranscription.cs +6 -0
  62. data/tracks/csharp/generators/Exercises/RomanNumerals.cs +4 -2
  63. data/tracks/csharp/generators/Exercises/RunLengthEncoding.cs +40 -0
  64. data/tracks/csharp/generators/Exercises/ScrabbleScore.cs +6 -0
  65. data/tracks/csharp/generators/Exercises/SecretHandshake.cs +15 -0
  66. data/tracks/csharp/generators/Exercises/Transpose.cs +4 -4
  67. data/tracks/csharp/generators/Exercises/TwoFer.cs +6 -0
  68. data/tracks/csharp/generators/Exercises/Wordy.cs +2 -10
  69. data/tracks/csharp/generators/Generators.csproj +1 -3
  70. data/tracks/csharp/generators/Input/CanonicalDataFile.cs +48 -11
  71. data/tracks/csharp/generators/Input/CanonicalDataOptions.cs +8 -0
  72. data/tracks/csharp/generators/Input/CanonicalDataParser.cs +11 -3
  73. data/tracks/csharp/generators/Options.cs +8 -0
  74. data/tracks/csharp/generators/Output/{TestClassFile.cs → ExerciseWriter.cs} +4 -3
  75. data/tracks/csharp/generators/Output/FormattingExtensions.cs +14 -0
  76. data/tracks/csharp/generators/Output/IndentFilter.cs +13 -0
  77. data/tracks/csharp/generators/Output/TemplateRenderer.cs +23 -0
  78. data/tracks/csharp/generators/Output/Templates/_Act.liquid +1 -0
  79. data/tracks/csharp/generators/Output/Templates/_Arrange.liquid +3 -0
  80. data/tracks/csharp/generators/Output/Templates/_AssertBoolean.liquid +1 -0
  81. data/tracks/csharp/generators/Output/Templates/_AssertEqual.liquid +1 -0
  82. data/tracks/csharp/generators/Output/Templates/_AssertEqual_Empty.liquid +1 -0
  83. data/tracks/csharp/generators/Output/Templates/_AssertNull.liquid +1 -0
  84. data/tracks/csharp/generators/Output/Templates/_AssertThrowsException.liquid +1 -0
  85. data/tracks/csharp/generators/Output/{TestClass.liquid → Templates/_TestClass.liquid} +2 -8
  86. data/tracks/csharp/generators/Output/Templates/_TestMethod.liquid +5 -0
  87. data/tracks/csharp/generators/Output/Templates/_TestMethodBody.liquid +3 -0
  88. data/tracks/csharp/generators/Output/TestClass.cs +5 -2
  89. data/tracks/csharp/generators/Output/TestMethod.cs +6 -6
  90. data/tracks/csharp/generators/Output/TestMethodBody.cs +49 -0
  91. data/tracks/csharp/generators/Output/TestMethodBodyData.cs +85 -0
  92. data/tracks/csharp/generators/Output/TestMethodBodyWithBooleanCheck.cs +16 -0
  93. data/tracks/csharp/generators/Output/TestMethodBodyWithEqualityCheck.cs +21 -0
  94. data/tracks/csharp/generators/Output/TestMethodBodyWithExceptionCheck.cs +18 -0
  95. data/tracks/csharp/generators/Output/TestMethodBodyWithNullCheck.cs +13 -0
  96. data/tracks/csharp/generators/Output/UnescapedValue.cs +6 -2
  97. data/tracks/csharp/generators/Output/ValueFormatter.cs +1 -10
  98. data/tracks/csharp/generators/Program.cs +34 -8
  99. data/tracks/delphi/config/maintainers.json +1 -1
  100. data/tracks/delphi/docs/{Getting_Started_Guide.md → GETTING_STARTED_GUIDE.md} +0 -0
  101. data/tracks/fsharp/config.json +16 -5
  102. data/tracks/fsharp/config/maintainers.json +3 -3
  103. data/tracks/fsharp/exercises/two-fer/Example.fs +4 -0
  104. data/tracks/fsharp/exercises/two-fer/README.md +28 -0
  105. data/tracks/fsharp/exercises/two-fer/TwoFerTest.fs +19 -0
  106. data/tracks/groovy/CONTRIBUTING.md +19 -0
  107. data/tracks/groovy/README.md +10 -2
  108. data/tracks/java/exercises/allergies/src/example/java/Allergies.java +1 -1
  109. data/tracks/r/bin/run_tests.R +1 -4
  110. data/tracks/r/docs/{snippet.txt → SNIPPET.txt} +0 -0
  111. data/tracks/r/exercises/hamming/example.R +1 -1
  112. data/tracks/ruby/exercises/flatten-array/README.md +1 -1
  113. data/tracks/scala/exercises/gigasecond/example.scala +3 -3
  114. data/tracks/scala/exercises/gigasecond/src/main/scala/Gigasecond.scala +2 -2
  115. data/tracks/scala/exercises/gigasecond/src/test/scala/GigasecondTest.scala +12 -21
  116. data/tracks/scala/exercises/house/example.scala +6 -3
  117. data/tracks/scala/exercises/house/src/test/scala/HouseTest.scala +289 -97
  118. data/tracks/scala/exercises/isogram/src/main/scala/{Isogram.scala → .keep} +0 -0
  119. data/tracks/scala/exercises/isogram/src/test/scala/IsogramTest.scala +16 -19
  120. data/tracks/scala/testgen/src/main/scala/GigasecondTestGenerator.scala +49 -0
  121. data/tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala +47 -0
  122. data/tracks/scala/testgen/src/main/scala/IsogramTestGenerator.scala +10 -31
  123. data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +3 -3
  124. data/tracks/scala/testgen/src/main/twirl/funSuiteTemplate.scala.txt +5 -1
  125. data/tracks/swift/config.json +11 -0
  126. data/tracks/swift/exercises/rotational-cipher/.gitignore +4 -0
  127. data/tracks/swift/exercises/rotational-cipher/Package.swift +5 -0
  128. data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipher.swift +1 -0
  129. data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipherExample.swift +30 -0
  130. data/tracks/swift/exercises/rotational-cipher/Tests/LinuxMain.swift +6 -0
  131. data/tracks/swift/exercises/rotational-cipher/Tests/RotationalCipherTests/RotationalCipherTests.swift +70 -0
  132. metadata +51 -17
  133. data/tracks/csharp/generators/Output/BooleanTestMethodGenerator.cs +0 -13
  134. data/tracks/csharp/generators/Output/EqualityTestMethodGenerator.cs +0 -27
  135. data/tracks/csharp/generators/Output/ExceptionTestMethodGenerator.cs +0 -15
  136. data/tracks/csharp/generators/Output/TestClassGenerator.cs +0 -30
  137. data/tracks/csharp/generators/Output/TestClassRenderer.cs +0 -26
  138. data/tracks/csharp/generators/Output/TestMethodGenerator.cs +0 -94
  139. data/tracks/java/docs/img/eclipse-help-dropdown.png +0 -0
  140. data/tracks/java/docs/img/eclipse-mp-search-buildship-gradle.png +0 -0
  141. data/tracks/java/docs/img/mac-osx--idea-ce-run-unit-tests.png +0 -0
  142. data/tracks/java/docs/img/mac-osx--install-java-dialog.png +0 -0
@@ -0,0 +1,5 @@
1
+ [Fact{% if Skip %}(Skip = "Remove to run test"){% endif %}]
2
+ public void {{ Name }}()
3
+ {
4
+ {{ Body | indent }}
5
+ }
@@ -0,0 +1,3 @@
1
+ {{ Arrange }}
2
+ {{ Act }}
3
+ {{ Assert }}
@@ -6,7 +6,10 @@ public class TestClass
6
6
  {
7
7
  public string ClassName { get; set; }
8
8
  public string CanonicalDataVersion { get; set; }
9
- public TestMethod[] TestMethods { get; set; }
10
- public ISet<string> UsingNamespaces { get; } = new HashSet<string> { "Xunit" };
9
+ public IList<string> Methods { get; set; }
10
+ public ISet<string> UsingNamespaces { get; set; } = new HashSet<string> { "Xunit" };
11
+ public string TemplateName { get; set; } = "TestClass";
12
+
13
+ public string Render() => TemplateRenderer.RenderPartial(TemplateName, new { ClassName, CanonicalDataVersion, Methods, UsingNamespaces });
11
14
  }
12
15
  }
@@ -1,12 +1,12 @@
1
- using System.Collections.Generic;
2
- using Generators.Input;
3
-
4
1
  namespace Generators.Output
5
2
  {
6
3
  public class TestMethod
7
4
  {
8
- public string MethodName { get; set; }
9
- public IEnumerable<string> Body { get; set; }
10
- public CanonicalDataCase GeneratedFrom { get; set; }
5
+ public bool Skip { get; set; }
6
+ public string Name { get; set; }
7
+ public string Body { get; set; }
8
+ public string TemplateName { get; set; } = "TestMethod";
9
+
10
+ public string Render() => TemplateRenderer.RenderPartial(TemplateName, new { Name, Body, Skip });
11
11
  }
12
12
  }
@@ -0,0 +1,49 @@
1
+ using Generators.Input;
2
+
3
+ namespace Generators.Output
4
+ {
5
+ public abstract class TestMethodBody
6
+ {
7
+ protected TestMethodBody(CanonicalDataCase canonicalDataCase, CanonicalData canonicalData)
8
+ {
9
+ CanonicalDataCase = canonicalDataCase;
10
+ CanonicalData = canonicalData;
11
+
12
+ Data = new TestMethodBodyData(this);
13
+ InitializeTemplateParameters();
14
+ }
15
+
16
+ public string TemplateName { get; set; } = "TestMethodBody";
17
+
18
+ public CanonicalDataCase CanonicalDataCase { get; }
19
+ public CanonicalData CanonicalData { get; }
20
+ public TestMethodBodyData Data { get; }
21
+
22
+ public virtual bool UseVariablesForInput => CanonicalDataCase.UseVariablesForInput;
23
+ public virtual bool UseVariablesForConstructorParameters => CanonicalDataCase.UseVariablesForConstructorParameters;
24
+ public virtual bool UseVariableForExpected => CanonicalDataCase.UseVariableForExpected;
25
+ public virtual bool UseVariableForTested => CanonicalDataCase.UseVariableForTested;
26
+
27
+ public string ArrangeTemplateName { get; set; } = "Arrange";
28
+ public object ArrangeTemplateParameters { get; set; }
29
+
30
+ public string ActTemplateName { get; set; } = "Act";
31
+ public object ActTemplateParameters { get; set; }
32
+
33
+ public string AssertTemplateName { get; set; } = "AssertEqual";
34
+ public object AssertTemplateParameters { get; set; }
35
+
36
+ public string Act { get; set; }
37
+ public string Arrange { get; set; }
38
+ public string Assert { get; set; }
39
+
40
+ public virtual string Render() => TemplateRenderer.RenderPartial(TemplateName, new { Arrange, Act, Assert });
41
+
42
+ private void InitializeTemplateParameters()
43
+ {
44
+ ArrangeTemplateParameters = new { Data.Variables };
45
+ ActTemplateParameters = new { };
46
+ AssertTemplateParameters = new { Data.ExpectedParameter, Data.TestedValue };
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,85 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using Generators.Input;
5
+
6
+ namespace Generators.Output
7
+ {
8
+ public class TestMethodBodyData
9
+ {
10
+ private const string SutVariableName = "sut";
11
+ private const string TestedVariableName = "actual";
12
+ private const string ExpectedVariableName = "expected";
13
+
14
+ private readonly TestMethodBody _testMethodBody;
15
+
16
+ public TestMethodBodyData(TestMethodBody testMethodBody)
17
+ {
18
+ _testMethodBody = testMethodBody;
19
+ }
20
+
21
+ public object TestedValue => _testMethodBody.UseVariableForTested ? TestedVariableName : TestedMethodInvocation;
22
+ public object InputParameters => _testMethodBody.UseVariablesForInput ? string.Join(", ", CanonicalDataCase.Input.Keys.Select(key => NameExtensions.ToVariableName(key))) : Input;
23
+ public object ExpectedParameter => _testMethodBody.UseVariableForExpected ? ExpectedVariableName : Expected;
24
+ public object ConstructorParameters => _testMethodBody.UseVariablesForConstructorParameters ? string.Join(", ", CanonicalDataCase.ConstructorInput.Keys.Select(key => key.ToVariableName())) : ConstructorInput;
25
+
26
+ private CanonicalDataCase CanonicalDataCase => _testMethodBody.CanonicalDataCase;
27
+ private CanonicalData CanonicalData => _testMethodBody.CanonicalData;
28
+
29
+ private string TestedClassName => CanonicalData.Exercise.ToTestedClassName();
30
+ private string TestedMethodName => CanonicalDataCase.Property.ToTestedMethodName();
31
+
32
+ private object Input => ValueFormatter.Format(CanonicalDataCase.Input);
33
+ private object Expected => ValueFormatter.Format(CanonicalDataCase.Expected);
34
+ private object ConstructorInput => ValueFormatter.Format(CanonicalDataCase.ConstructorInput);
35
+
36
+ private IEnumerable<string> InputVariablesDeclaration => ValueFormatter.FormatVariables(CanonicalDataCase.Input);
37
+ private IEnumerable<string> ExpectedVariableDeclaration => ValueFormatter.FormatVariable(CanonicalDataCase.Expected, ExpectedVariableName);
38
+ private IEnumerable<string> ConstructorVariablesDeclaration => ValueFormatter.FormatVariables(CanonicalDataCase.ConstructorInput);
39
+ private IEnumerable<string> SutVariableDeclaration => new[] { $"var {SutVariableName} = new {TestedClassName}({ConstructorParameters});" };
40
+ private IEnumerable<string> ActualVariableDeclaration => new[] { $"var {TestedVariableName} = {TestedMethodInvocation};" };
41
+
42
+ public IEnumerable<string> Variables
43
+ {
44
+ get
45
+ {
46
+ var lines = new List<string>();
47
+
48
+ if (_testMethodBody.UseVariablesForInput)
49
+ lines.AddRange(InputVariablesDeclaration);
50
+
51
+ if (_testMethodBody.UseVariablesForConstructorParameters)
52
+ lines.AddRange(ConstructorVariablesDeclaration);
53
+
54
+ if (CanonicalDataCase.TestedMethodType == TestedMethodType.Instance)
55
+ lines.AddRange(SutVariableDeclaration);
56
+
57
+ if (_testMethodBody.UseVariableForTested)
58
+ lines.AddRange(ActualVariableDeclaration);
59
+
60
+ if (_testMethodBody.UseVariableForExpected)
61
+ lines.AddRange(ExpectedVariableDeclaration);
62
+
63
+ return lines;
64
+ }
65
+ }
66
+
67
+ public string TestedMethodInvocation
68
+ {
69
+ get
70
+ {
71
+ switch (CanonicalDataCase.TestedMethodType)
72
+ {
73
+ case TestedMethodType.Static:
74
+ return $"{TestedClassName}.{TestedMethodName}({InputParameters})";
75
+ case TestedMethodType.Instance:
76
+ return $"{SutVariableName}.{TestedMethodName}({InputParameters})";
77
+ case TestedMethodType.Extension:
78
+ return $"{InputParameters}.{TestedMethodName}()";
79
+ default:
80
+ throw new ArgumentOutOfRangeException();
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,16 @@
1
+ using System;
2
+ using Generators.Input;
3
+
4
+ namespace Generators.Output
5
+ {
6
+ public class TestMethodBodyWithBooleanCheck : TestMethodBody
7
+ {
8
+ public TestMethodBodyWithBooleanCheck(CanonicalDataCase canonicalDataCase, CanonicalData canonicalData) : base(canonicalDataCase, canonicalData)
9
+ {
10
+ AssertTemplateName = "AssertBoolean";
11
+ AssertTemplateParameters = new { BooleanAssertMethod, Data.TestedValue };
12
+ }
13
+
14
+ private string BooleanAssertMethod => Convert.ToBoolean(CanonicalDataCase.Expected).ToString();
15
+ }
16
+ }
@@ -0,0 +1,21 @@
1
+ using System.Collections;
2
+ using Generators.Input;
3
+
4
+ namespace Generators.Output
5
+ {
6
+ public class TestMethodBodyWithEqualityCheck : TestMethodBody
7
+ {
8
+ public TestMethodBodyWithEqualityCheck(CanonicalDataCase canonicalDataCase, CanonicalData canonicalData) : base(canonicalDataCase, canonicalData)
9
+ {
10
+ AssertTemplateName = ExpectedIsEmptyEnumerable ? "AssertEqual_Empty" : "AssertEqual";
11
+ AssertTemplateParameters = new { Data.ExpectedParameter, Data.TestedValue };
12
+ }
13
+
14
+ public override bool UseVariableForExpected => base.UseVariableForExpected && !ExpectedIsEmptyEnumerable;
15
+
16
+ private bool ExpectedIsEmptyEnumerable =>
17
+ !(CanonicalDataCase.Expected is string) &&
18
+ CanonicalDataCase.Expected is IEnumerable enumerable
19
+ && enumerable.GetEnumerator().MoveNext() == false;
20
+ }
21
+ }
@@ -0,0 +1,18 @@
1
+ using Generators.Input;
2
+
3
+ namespace Generators.Output
4
+ {
5
+ public class TestMethodBodyWithExceptionCheck : TestMethodBody
6
+ {
7
+ public TestMethodBodyWithExceptionCheck(CanonicalDataCase canonicalDataCase, CanonicalData canonicalData) : base(canonicalDataCase, canonicalData)
8
+ {
9
+ AssertTemplateName = "AssertThrowsException";
10
+ AssertTemplateParameters = new { ExceptionType, Data.TestedValue };
11
+ }
12
+
13
+ public override bool UseVariableForExpected => false;
14
+ public override bool UseVariableForTested => false;
15
+
16
+ private string ExceptionType => CanonicalDataCase.ExceptionThrown.Name;
17
+ }
18
+ }
@@ -0,0 +1,13 @@
1
+ using Generators.Input;
2
+
3
+ namespace Generators.Output
4
+ {
5
+ public class TestMethodBodyWithNullCheck : TestMethodBody
6
+ {
7
+ public TestMethodBodyWithNullCheck(CanonicalDataCase canonicalDataCase, CanonicalData canonicalData) : base(canonicalDataCase, canonicalData)
8
+ {
9
+ AssertTemplateName = "AssertNull";
10
+ AssertTemplateParameters = new { Data.TestedValue };
11
+ }
12
+ }
13
+ }
@@ -1,11 +1,15 @@
1
- namespace Generators.Output
1
+ using DotLiquid;
2
+
3
+ namespace Generators.Output
2
4
  {
3
- public class UnescapedValue
5
+ public class UnescapedValue : ILiquidizable
4
6
  {
5
7
  private readonly string _value;
6
8
 
7
9
  public UnescapedValue(string value) => _value = value;
8
10
 
9
11
  public override string ToString() => _value;
12
+
13
+ public object ToLiquid() => _value;
10
14
  }
11
15
  }
@@ -78,16 +78,7 @@ private static string[] FormatMultiLineVariable(IEnumerable<string> enumerable,
78
78
  .AddTrailingSemicolon()
79
79
  .Prepend($"var {name} = {constructor}")
80
80
  .ToArray();
81
-
82
- private static string EscapeControlCharacters(this string s)
83
- => s.Replace("\n", "\\n")
84
- .Replace("\t", "\\t")
85
- .Replace("\r", "\\r");
86
-
87
- private static string Quote(this string s) => $"\"{s}\"";
88
-
89
- private static string Indent(this string s, int level = 1) => $"{new string(' ', 4 * level)}{s}";
90
-
81
+
91
82
  private static IEnumerable<string> AddTrailingSemicolon(this IEnumerable<string> enumerable)
92
83
  {
93
84
  var array = enumerable.ToArray();
@@ -1,16 +1,27 @@
1
- using CommandLine;
1
+ using System;
2
+ using CommandLine;
3
+ using Generators.Input;
2
4
  using Serilog;
3
5
 
4
6
  namespace Generators
5
7
  {
6
8
  public static class Program
7
9
  {
8
- public static void Main(string[] args)
10
+ public static int Main(string[] args)
9
11
  {
10
12
  SetupLogger();
11
13
 
12
- Parser.Default.ParseArguments<Options>(args)
13
- .WithParsed(Generate);
14
+ try
15
+ {
16
+ Parser.Default.ParseArguments<Options>(args)
17
+ .WithParsed(RegenerateTestClasses);
18
+ return 0;
19
+ }
20
+ catch (Exception exception)
21
+ {
22
+ Log.Error(exception, "Exception occured: {Message}", exception.Message);
23
+ return 1;
24
+ }
14
25
  }
15
26
 
16
27
  private static void SetupLogger()
@@ -20,14 +31,29 @@ private static void SetupLogger()
20
31
  .CreateLogger();
21
32
  }
22
33
 
23
- private static void Generate(Options options)
34
+ private static void RegenerateTestClasses(Options options)
24
35
  {
25
- Log.Information("Generating tests...");
36
+ Log.Information("Re-generating test classes...");
37
+
38
+ var canonicalDataParser = CreateCanonicalDataParser(options);
26
39
 
27
40
  foreach (var exercise in new ExerciseCollection(options.Exercises))
28
- exercise.Generate();
41
+ {
42
+ var canonicalData = canonicalDataParser.Parse(exercise);
43
+ exercise.Regenerate(canonicalData);
44
+ }
29
45
 
30
- Log.Information("Generated tests.");
46
+ Log.Information("Re-generated test classes.");
47
+ }
48
+
49
+ private static CanonicalDataParser CreateCanonicalDataParser(Options options)
50
+ {
51
+ var canonicalDataOptions = new CanonicalDataOptions
52
+ {
53
+ CanonicalDataDirectory = options.CanonicalDataDirectory,
54
+ CacheCanonicalData = options.CacheCanonicalData
55
+ };
56
+ return new CanonicalDataParser(canonicalDataOptions);
31
57
  }
32
58
  }
33
59
  }
@@ -15,7 +15,7 @@
15
15
  "show_on_website": true,
16
16
  "alumnus": false,
17
17
  "name": "Ryan Potts",
18
- "bio": "I have been using Delphi professionally since 1996, Delphi 1. My day job has me developing software used in the control of various types of electromechanical testing machines used by the auto industry. Exercism is my first real push into Open Source and I'm happy to have the opportunity here to teach and share the virtures of this programming language with others.",
18
+ "bio": "I have been using Delphi professionally since 1996, Delphi 1. At my day job I develope software used in the control of various types of test machines used by the auto industry. Exercism is my first real push into Open Source and I'm happy to have this opportunity to teach and share the virtures of Delphi with others.",
19
19
  "link_text": null,
20
20
  "link_url": null,
21
21
  "avatar_url": null
@@ -45,6 +45,17 @@
45
45
  "Lists",
46
46
  "Transforming"
47
47
  ]
48
+ },
49
+ {
50
+ "uuid": "2ee3cc7a-db3f-4668-9983-ed6d0fea95d1",
51
+ "slug": "two-fer",
52
+ "core": true,
53
+ "unlocked_by": "null",
54
+ "difficulty": 1,
55
+ "topics": [
56
+ "Strings",
57
+ "Optional values"
58
+ ]
48
59
  },
49
60
  {
50
61
  "uuid": "277d05db-0ba0-4de6-b5f8-090c251afffc",
@@ -181,8 +192,8 @@
181
192
  {
182
193
  "uuid": "4e786e56-2658-445f-ac91-64dd9c38dbb3",
183
194
  "slug": "binary-search-tree",
184
- "core": true,
185
- "unlocked_by": null,
195
+ "core": false,
196
+ "unlocked_by": "two-fer",
186
197
  "difficulty": 5,
187
198
  "topics": [
188
199
  "Searching",
@@ -769,7 +780,7 @@
769
780
  "uuid": "cb629d30-0351-4023-bd51-423267164c24",
770
781
  "slug": "bank-account",
771
782
  "core": false,
772
- "unlocked_by": "binary-search-tree",
783
+ "unlocked_by": "two-fer",
773
784
  "difficulty": 5,
774
785
  "topics": [
775
786
  "Optional values",
@@ -1125,7 +1136,7 @@
1125
1136
  "uuid": "5369eea9-00c8-4044-b272-1ce8d0590ecf",
1126
1137
  "slug": "zipper",
1127
1138
  "core": false,
1128
- "unlocked_by": "binary-search-tree",
1139
+ "unlocked_by": "two-fer",
1129
1140
  "difficulty": 10,
1130
1141
  "topics": [
1131
1142
  "Trees",
@@ -1148,7 +1159,7 @@
1148
1159
  "uuid": "a6082751-98ca-45dc-aeed-cdd19a8da0ca",
1149
1160
  "slug": "pov",
1150
1161
  "core": false,
1151
- "unlocked_by": "binary-search-tree",
1162
+ "unlocked_by": "two-fer",
1152
1163
  "difficulty": 10,
1153
1164
  "topics": [
1154
1165
  "Graphs",
@@ -22,10 +22,10 @@
22
22
  },
23
23
  {
24
24
  "github_username": "robkeim",
25
- "show_on_website": false,
25
+ "show_on_website": true,
26
26
  "alumnus": false,
27
- "name": null,
28
- "bio": null,
27
+ "name": "Rob Keim",
28
+ "bio": "I stumbled upon this site when I was trying to learn about functional programming and F#. Little did I know, I'd wind up becoming a contributor and learning a whole lot more than what I originally intended to. I had never contributed to an open source project before, and it's been a very rewarding experience.",
29
29
  "link_text": null,
30
30
  "link_url": null,
31
31
  "avatar_url": null