trackler 2.0.6.22 → 2.0.6.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/book-store/canonical-data.json +61 -80
  3. data/common/exercises/etl/canonical-data.json +69 -0
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/go/config.json +10 -4
  6. data/tracks/java/config.json +13 -1
  7. data/tracks/java/exercises/diamond/build.gradle +17 -0
  8. data/tracks/java/exercises/diamond/src/example/java/DiamondPrinter.java +41 -0
  9. data/tracks/java/exercises/diamond/src/main/java/DiamondPrinter.java +5 -0
  10. data/tracks/java/exercises/diamond/src/test/java/DiamondPrinterTest.java +111 -0
  11. data/tracks/java/exercises/grade-school/src/example/java/School.java +20 -19
  12. data/tracks/java/exercises/grade-school/src/test/java/SchoolTest.java +53 -20
  13. data/tracks/java/exercises/secret-handshake/build.gradle +17 -0
  14. data/tracks/java/exercises/secret-handshake/src/example/java/HandshakeCalculator.java +29 -0
  15. data/tracks/java/exercises/secret-handshake/src/example/java/Signal.java +1 -0
  16. data/tracks/java/exercises/secret-handshake/src/main/java/HandshakeCalculator.java +5 -0
  17. data/tracks/java/exercises/secret-handshake/src/main/java/Signal.java +5 -0
  18. data/tracks/java/exercises/secret-handshake/src/test/java/HandshakeCalculatorTest.java +106 -0
  19. data/tracks/java/exercises/settings.gradle +2 -0
  20. data/tracks/julia/config.json +42 -0
  21. data/tracks/julia/exercises/bob/bob.jl +3 -0
  22. data/tracks/julia/exercises/bob/example.jl +30 -0
  23. data/tracks/julia/exercises/bob/runtests.jl +70 -0
  24. data/tracks/julia/exercises/difference-of-squares/difference-of-squares.jl +14 -0
  25. data/tracks/julia/exercises/difference-of-squares/example.jl +9 -0
  26. data/tracks/julia/exercises/difference-of-squares/runtests.jl +22 -0
  27. data/tracks/julia/exercises/hamming/example.jl +5 -0
  28. data/tracks/julia/exercises/hamming/hamming.jl +3 -0
  29. data/tracks/julia/exercises/hamming/runtests.jl +42 -0
  30. data/tracks/julia/exercises/hello-world/example.jl +3 -0
  31. data/tracks/julia/exercises/hello-world/hello-world.jl +3 -0
  32. data/tracks/julia/exercises/hello-world/runtests.jl +12 -0
  33. data/tracks/julia/exercises/word-count/example.jl +9 -0
  34. data/tracks/julia/exercises/word-count/runtests.jl +47 -0
  35. data/tracks/julia/exercises/word-count/word-count.jl +3 -0
  36. data/tracks/objective-c/config.json +10 -0
  37. data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.h +6 -0
  38. data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.m +48 -0
  39. data/tracks/objective-c/exercises/flatten-array/FlattenArrayTest.m +110 -0
  40. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +33 -0
  41. data/tracks/ocaml/config.json +5 -0
  42. data/tracks/ocaml/exercises/pangram/.merlin +3 -0
  43. data/tracks/ocaml/exercises/pangram/Makefile +11 -0
  44. data/tracks/ocaml/exercises/pangram/example.ml +9 -0
  45. data/tracks/ocaml/exercises/pangram/pangram.mli +1 -0
  46. data/tracks/ocaml/exercises/pangram/test.ml +29 -0
  47. data/tracks/ocaml/tools/test-generator/templates/pangram/template.ml +15 -0
  48. data/tracks/pascal/config.json +8 -0
  49. data/tracks/pascal/docs/INSTALLATION.md +3 -3
  50. data/tracks/pascal/docs/img/07delphiclicklibrarypathbuttonLogo.png +0 -0
  51. data/tracks/pascal/exercises/grains/GrainsTests.dpr +60 -0
  52. data/tracks/pascal/exercises/grains/uGrainsExample.pas +33 -0
  53. data/tracks/pascal/exercises/grains/uGrainsTests.pas +149 -0
  54. data/tracks/perl6/SETUP.md +8 -2
  55. metadata +41 -2
@@ -48,6 +48,11 @@
48
48
  1EFACABB1CCCAF3D006F2E69 /* WordCountExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EFACAA11CCCAF3D006F2E69 /* WordCountExample.m */; };
49
49
  1EFACABC1CCCAF3D006F2E69 /* WordCountTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EFACAA21CCCAF3D006F2E69 /* WordCountTest.m */; };
50
50
 
51
+ A09A4C031E38761A00FEFB7A /* FlattenArrayExample.m in Sources */ = {isa = PBXBuildFile; fileRef = A09A4C021E38761A00FEFB7A /* FlattenArrayExample.m */; };
52
+ A09A4C051E38763300FEFB7A /* FlattenArrayTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A09A4C041E38763300FEFB7A /* FlattenArrayTest.m */; };
53
+ E907D0CA1D6B731600106C42 /* GigasecondExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E907D0C91D6B731600106C42 /* GigasecondExample.m */; };
54
+
55
+
51
56
  A0BBFCBF1E37719800230071 /* SublistExample.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BBFCBE1E37719800230071 /* SublistExample.m */; };
52
57
  A0BBFCC31E37728100230071 /* SublistTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BBFCC21E37728100230071 /* SublistTest.m */; };
53
58
 
@@ -141,6 +146,11 @@
141
146
  1EFACAA11CCCAF3D006F2E69 /* WordCountExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordCountExample.m; path = "../../exercises/word-count/WordCountExample.m"; sourceTree = "<group>"; };
142
147
  1EFACAA21CCCAF3D006F2E69 /* WordCountTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordCountTest.m; path = "../../exercises/word-count/WordCountTest.m"; sourceTree = "<group>"; };
143
148
 
149
+ A09A4C011E38761A00FEFB7A /* FlattenArrayExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FlattenArrayExample.h; path = "../../exercises/flatten-array/FlattenArrayExample.h"; sourceTree = "<group>"; };
150
+ A09A4C021E38761A00FEFB7A /* FlattenArrayExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FlattenArrayExample.m; path = "../../exercises/flatten-array/FlattenArrayExample.m"; sourceTree = "<group>"; };
151
+ A09A4C041E38763300FEFB7A /* FlattenArrayTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FlattenArrayTest.m; path = "../../exercises/flatten-array/FlattenArrayTest.m"; sourceTree = "<group>"; };
152
+
153
+
144
154
  A0BBFCBD1E37719800230071 /* SublistExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SublistExample.h; path = ../../exercises/sublist/SublistExample.h; sourceTree = "<group>"; };
145
155
  A0BBFCBE1E37719800230071 /* SublistExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SublistExample.m; path = ../../exercises/sublist/SublistExample.m; sourceTree = "<group>"; };
146
156
  A0BBFCC21E37728100230071 /* SublistTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SublistTest.m; path = ../../exercises/sublist/SublistTest.m; sourceTree = "<group>"; };
@@ -155,6 +165,7 @@
155
165
  A065F5771E3098080048E337 /* BeerSongTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BeerSongTest.m; path = "../../exercises/beer-song/BeerSongTest.m"; sourceTree = "<group>"; };
156
166
 
157
167
 
168
+
158
169
  E907D0C81D6B731600106C42 /* GigasecondExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GigasecondExample.h; path = ../../exercises/gigasecond/GigasecondExample.h; sourceTree = "<group>"; };
159
170
  E907D0C91D6B731600106C42 /* GigasecondExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GigasecondExample.m; path = ../../exercises/gigasecond/GigasecondExample.m; sourceTree = "<group>"; };
160
171
  E907D0CB1D6B734800106C42 /* GigasecondTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GigasecondTest.m; path = ../../exercises/gigasecond/GigasecondTest.m; sourceTree = "<group>"; };
@@ -239,6 +250,7 @@
239
250
  E9381D4F1D8F2DA4003F22A1 /* Clock */,
240
251
  E9381D431D8EDFB8003F22A1 /* DifferenceOfSquares */,
241
252
  E9E8B6ED1D519DF50012F12C /* Etl */,
253
+ A09A4C001E3875C200FEFB7A /* FlattenArray */,
242
254
  E907D0C71D6B72B600106C42 /* Gigasecond */,
243
255
  E9E8B6EE1D519DFE0012F12C /* GradeSchool */,
244
256
  E9E8B6EF1D519E040012F12C /* Hamming */,
@@ -285,6 +297,18 @@
285
297
  sourceTree = "<group>";
286
298
  };
287
299
 
300
+ A09A4C001E3875C200FEFB7A /* FlattenArray */ = {
301
+ isa = PBXGroup;
302
+ children = (
303
+ A09A4C011E38761A00FEFB7A /* FlattenArrayExample.h */,
304
+ A09A4C021E38761A00FEFB7A /* FlattenArrayExample.m */,
305
+ A09A4C041E38763300FEFB7A /* FlattenArrayTest.m */,
306
+ );
307
+ name = FlattenArray;
308
+ sourceTree = "<group>";
309
+ };
310
+
311
+
288
312
  A0BBFCBC1E37703D00230071 /* Sublist */ = {
289
313
  isa = PBXGroup;
290
314
  children = (
@@ -320,6 +344,7 @@
320
344
  };
321
345
 
322
346
 
347
+
323
348
  E907D0C71D6B72B600106C42 /* Gigasecond */ = {
324
349
  isa = PBXGroup;
325
350
  children = (
@@ -734,7 +759,11 @@
734
759
  E9C1C0291D9DB16B0015E86E /* AcronymExample.m in Sources */,
735
760
  1EFACAA41CCCAF3D006F2E69 /* AnagramTest.m in Sources */,
736
761
  E907FE921D87547D00B93DA9 /* ScrabbleScoreExample.m in Sources */,
762
+
763
+ A09A4C051E38763300FEFB7A /* FlattenArrayTest.m in Sources */,
764
+
737
765
  A097D4101E363C2700EAF2C2 /* BracketPushTest.m in Sources */,
766
+
738
767
  1EFACABC1CCCAF3D006F2E69 /* WordCountTest.m in Sources */,
739
768
  1EFACAB11CCCAF3D006F2E69 /* NucleotideCountExample.m in Sources */,
740
769
  E9381D481D8EE00C003F22A1 /* DifferenceOfSquaresTest.m in Sources */,
@@ -750,7 +779,11 @@
750
779
  E9381D521D8F2DCC003F22A1 /* ClockExample.m in Sources */,
751
780
  E99D1D811D5533BF0006A303 /* SumOfMultiplesExample.m in Sources */,
752
781
  E9F390071DFCA337005C5F46 /* IsogramExample.m in Sources */,
782
+
783
+ A09A4C031E38761A00FEFB7A /* FlattenArrayExample.m in Sources */,
784
+
753
785
  A0BBFCC31E37728100230071 /* SublistTest.m in Sources */,
786
+
754
787
  E9C1C02F1D9EC1130015E86E /* RunLengthEncodingExample.m in Sources */,
755
788
  E92FCC0F1D78F3B600061017 /* MeetupTest.m in Sources */,
756
789
  E9381D4E1D8F2982003F22A1 /* RaindropsTest.m in Sources */,
@@ -71,6 +71,11 @@
71
71
  "difficulty": 3,
72
72
  "topics": []
73
73
  },
74
+ {
75
+ "slug": "pangram",
76
+ "difficulty": 3,
77
+ "topics": ["Strings"]
78
+ },
74
79
  {
75
80
  "slug": "all-your-base",
76
81
  "difficulty": 4,
@@ -0,0 +1,3 @@
1
+ PKG core oUnit
2
+ S *
3
+ B build/*
@@ -0,0 +1,11 @@
1
+ test: test.native
2
+ @./test.native
3
+
4
+ test.native: *.ml *.mli
5
+ @corebuild -r -quiet -pkg oUnit test.native
6
+
7
+ clean:
8
+ rm -rf _build
9
+ rm -f test.native
10
+
11
+ .PHONY: clean
@@ -0,0 +1,9 @@
1
+ open Core.Std
2
+
3
+ let string_to_set s = Char.Set.of_list (String.to_list s)
4
+
5
+ let alphabet_set = string_to_set "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
6
+
7
+ let is_pangram s =
8
+ let normalize s = String.filter ~f:Char.is_alpha s |> String.uppercase in
9
+ Set.equal alphabet_set (string_to_set @@ normalize s)
@@ -0,0 +1 @@
1
+ val is_pangram : string -> bool
@@ -0,0 +1,29 @@
1
+ open Core.Std
2
+ open OUnit2
3
+ open Pangram
4
+
5
+ let ae exp got _test_ctxt = assert_equal ~printer:Bool.to_string exp got
6
+
7
+ let tests = [
8
+ "sentence empty" >::
9
+ ae false (is_pangram "");
10
+ "pangram with only lower case" >::
11
+ ae true (is_pangram "the quick brown fox jumps over the lazy dog");
12
+ "missing character 'x'" >::
13
+ ae false (is_pangram "a quick movement of the enemy will jeopardize five gunboats");
14
+ "another missing character 'x'" >::
15
+ ae false (is_pangram "the quick brown fish jumps over the lazy dog");
16
+ "pangram with underscores" >::
17
+ ae true (is_pangram "the_quick_brown_fox_jumps_over_the_lazy_dog");
18
+ "pangram with numbers" >::
19
+ ae true (is_pangram "the 1 quick brown fox jumps over the 2 lazy dogs");
20
+ "missing letters replaced by numbers" >::
21
+ ae false (is_pangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog");
22
+ "pangram with mixed case and punctuation" >::
23
+ ae true (is_pangram "\"Five quacking Zephyrs jolt my wax bed.\"");
24
+ "upper and lower case versions of the same character should not be counted separately" >::
25
+ ae false (is_pangram "the quick brown fox jumped over the lazy FOX");
26
+ ]
27
+
28
+ let () =
29
+ run_test_tt_main ("pangram tests" >::: tests)
@@ -0,0 +1,15 @@
1
+ open Core.Std
2
+ open OUnit2
3
+ open Pangram
4
+
5
+ let ae exp got _test_ctxt = assert_equal ~printer:Bool.to_string exp got
6
+
7
+ let tests = [
8
+ (* TEST
9
+ "$description" >::
10
+ ae $expected (is_pangram "$input");
11
+ END TEST *)
12
+ ]
13
+
14
+ let () =
15
+ run_test_tt_main ("pangram tests" >::: tests)
@@ -59,6 +59,14 @@
59
59
  "Transforming"
60
60
  ]
61
61
  },
62
+ {
63
+ "slug": "grains",
64
+ "difficulty": 2,
65
+ "topics": [
66
+ "Integers",
67
+ "Recursion"
68
+ ]
69
+ },
62
70
  {
63
71
  "slug": "beer-song",
64
72
  "difficulty": 3,
@@ -23,7 +23,7 @@ If you had to install DUnitX because your installation didn't already come with
23
23
 
24
24
  *Note: it is assumed that you have completed the installation of Delphi by this point.*
25
25
 
26
- - Start Delphi. If your installation is new you will most likely end up at a Welcome Page similar to this.
26
+ - Start Delphi. If your installation is new you will most likely end up at a `Welcome Page` similar to this.
27
27
 
28
28
  [![Welcome Page](http://x.exercism.io/v3/tracks/pascal/docs/img/00delphiwelcomepageLogo.png)](http://x.exercism.io/v3/tracks/pascal/docs/img/00delphiwelcomepage.png)
29
29
 
@@ -49,11 +49,11 @@ If you had to install DUnitX because your installation didn't already come with
49
49
 
50
50
  - Locate and click on `Library` along the left side of the Options screen.
51
51
 
52
- ![[Library](http://x.exercism.io/v3/tracks/pascal/docs/img/06delphioptionslibraryLogo.png)](http://x.exercism.io/v3/tracks/pascal/docs/img/06delphioptionslibrary.png)
52
+ [![Library](http://x.exercism.io/v3/tracks/pascal/docs/img/06delphioptionslibraryLogo.png)](http://x.exercism.io/v3/tracks/pascal/docs/img/06delphioptionslibrary.png)
53
53
 
54
54
  - Click the `...` button associated with the Library path in the Directories group
55
55
 
56
- ![...button](http://x.exercism.io/v3/tracks/pascal/docs/img/07delphiclicklibrarypathbutton.png)
56
+ [![...button](http://x.exercism.io/v3/tracks/pascal/docs/img/07delphiclicklibrarypathbuttonLogo.png)](http://x.exercism.io/v3/tracks/pascal/docs/img/07delphiclicklibrarypathbutton.png)
57
57
 
58
58
  - In the Directories window enter the variable name that you created a few steps ago. The entry should appear like this `$(DUNITX)`
59
59
 
@@ -0,0 +1,60 @@
1
+ program GrainsTests;
2
+
3
+ {$IFNDEF TESTINSIGHT}
4
+ {$APPTYPE CONSOLE}
5
+ {$ENDIF}{$STRONGLINKTYPES ON}
6
+ uses
7
+ System.SysUtils,
8
+ {$IFDEF TESTINSIGHT}
9
+ TestInsight.DUnitX,
10
+ {$ENDIF }
11
+ DUnitX.Loggers.Console,
12
+ DUnitX.Loggers.Xml.NUnit,
13
+ DUnitX.TestFramework,
14
+ uGrainsTests in 'uGrainsTests.pas',
15
+ uGrains in 'uGrains.pas';
16
+
17
+ var
18
+ runner : ITestRunner;
19
+ results : IRunResults;
20
+ logger : ITestLogger;
21
+ nunitLogger : ITestLogger;
22
+ begin
23
+ {$IFDEF TESTINSIGHT}
24
+ TestInsight.DUnitX.RunRegisteredTests;
25
+ exit;
26
+ {$ENDIF}
27
+ try
28
+ //Check command line options, will exit if invalid
29
+ TDUnitX.CheckCommandLine;
30
+ //Create the test runner
31
+ runner := TDUnitX.CreateRunner;
32
+ //Tell the runner to use RTTI to find Fixtures
33
+ runner.UseRTTI := True;
34
+ //tell the runner how we will log things
35
+ //Log to the console window
36
+ logger := TDUnitXConsoleLogger.Create(true);
37
+ runner.AddLogger(logger);
38
+ //Generate an NUnit compatible XML File
39
+ nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
40
+ runner.AddLogger(nunitLogger);
41
+ runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;
42
+
43
+ //Run tests
44
+ results := runner.Execute;
45
+ if not results.AllPassed then
46
+ System.ExitCode := EXIT_ERRORS;
47
+
48
+ {$IFNDEF CI}
49
+ //We don't want this happening when running under CI.
50
+ if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
51
+ begin
52
+ System.Write('Done.. press <Enter> key to quit.');
53
+ System.Readln;
54
+ end;
55
+ {$ENDIF}
56
+ except
57
+ on E: Exception do
58
+ System.Writeln(E.ClassName, ': ', E.Message);
59
+ end;
60
+ end.
@@ -0,0 +1,33 @@
1
+ unit uGrains;
2
+
3
+ interface
4
+
5
+ type
6
+ Grains = class
7
+ class function Square(aInteger: integer): UInt64; static;
8
+ class function Total: UInt64; static;
9
+ end;
10
+
11
+ implementation
12
+ uses System.SysUtils;
13
+
14
+ class function Grains.Square(aInteger: integer): UInt64;
15
+ begin
16
+ if (aInteger < 1) or (aInteger > 64) then
17
+ raise ERangeError.CreateFmt('Argument of %d is out of bounds. Must be > 0 and < 65',[aInteger]);
18
+
19
+ if aInteger = 1 then
20
+ result := 1
21
+ else
22
+ result := 2 * Square(aInteger - 1);
23
+ end;
24
+
25
+ class function Grains.Total: UInt64;
26
+ var i: integer;
27
+ begin
28
+ result := 0;
29
+ for i := 1 to 64 do
30
+ result := result + Square(i);
31
+ end;
32
+
33
+ end.
@@ -0,0 +1,149 @@
1
+ unit uGrainsTests;
2
+
3
+ interface
4
+ uses
5
+ DUnitX.TestFramework;
6
+
7
+ type
8
+ [TestFixture]
9
+ TgrainsTests = class(TObject)
10
+ public
11
+ [Test]
12
+ procedure Test_square_1;
13
+
14
+ [Test]
15
+ [Ignore('Comment this line to run this test')]
16
+ procedure Test_square_2;
17
+
18
+ [Test]
19
+ [Ignore('Comment this line to run this test')]
20
+ procedure Test_square_3;
21
+
22
+ [Test]
23
+ [Ignore('Comment this line to run this test')]
24
+ procedure Test_square_4;
25
+
26
+ [Test]
27
+ [Ignore('Comment this line to run this test')]
28
+ procedure Test_square_16;
29
+
30
+ [Test]
31
+ [Ignore('Comment this line to run this test')]
32
+ procedure Test_square_32;
33
+
34
+ [Test]
35
+ [Ignore('Comment this line to run this test')]
36
+ procedure Test_square_64;
37
+
38
+ [Test]
39
+ [Ignore('Comment this line to run this test')]
40
+ procedure Square_0_raises_an_exception;
41
+
42
+ [Test]
43
+ [Ignore('Comment this line to run this test')]
44
+ procedure Negative_square_raises_an_exception;
45
+
46
+ [Test]
47
+ [Ignore('Comment this line to run the test')]
48
+ procedure Square_greater_than_64_raises_an_exception;
49
+
50
+ [Test]
51
+ [Ignore('Comment this line to run this test')]
52
+ procedure Test_total_grains;
53
+ end;
54
+
55
+ implementation
56
+ uses System.SysUtils, uGrains;
57
+
58
+ procedure TgrainsTests.Test_square_1;
59
+ var expected: UInt64;
60
+ begin
61
+ expected := 1;
62
+ Assert.AreEqual(expected, Grains.Square(1));
63
+ end;
64
+
65
+ procedure TgrainsTests.Test_square_2;
66
+ var expected: UInt64;
67
+ begin
68
+ expected := 2;
69
+ Assert.AreEqual(expected, Grains.Square(2));
70
+ end;
71
+
72
+ procedure TgrainsTests.Test_square_3;
73
+ var expected: UInt64;
74
+ begin
75
+ expected := 4;
76
+ Assert.AreEqual(expected, Grains.Square(3));
77
+ end;
78
+
79
+ procedure TgrainsTests.Test_square_4;
80
+ var expected: UInt64;
81
+ begin
82
+ expected := 8;
83
+ Assert.AreEqual(expected, Grains.Square(4));
84
+ end;
85
+
86
+ procedure TgrainsTests.Test_square_16;
87
+ var expected: UInt64;
88
+ begin
89
+ expected := 32768;
90
+ Assert.AreEqual(expected, Grains.Square(16));
91
+ end;
92
+
93
+ procedure TgrainsTests.Test_square_32;
94
+ var expected: UInt64;
95
+ begin
96
+ expected := 2147483648;
97
+ Assert.AreEqual(expected, Grains.Square(32));
98
+ end;
99
+
100
+ procedure TgrainsTests.Test_square_64;
101
+ var expected: UInt64;
102
+ begin
103
+ expected := 9223372036854775808;
104
+ Assert.AreEqual(expected, Grains.Square(64));
105
+ end;
106
+
107
+ procedure TgrainsTests.Square_0_raises_an_exception;
108
+ var MyProc: TTestLocalMethod;
109
+ begin
110
+ MyProc := procedure
111
+ begin
112
+ Grains.Square(0);
113
+ end;
114
+
115
+ Assert.WillRaise(MyProc, ERangeError);
116
+ end;
117
+
118
+ procedure TgrainsTests.Negative_square_raises_an_exception;
119
+ var MyProc: TTestLocalMethod;
120
+ begin
121
+ MyProc := procedure
122
+ begin
123
+ Grains.Square(-1);
124
+ end;
125
+
126
+ Assert.WillRaise(MyProc, ERangeError);
127
+ end;
128
+
129
+ procedure TgrainsTests.Square_greater_than_64_raises_an_exception;
130
+ var MyProc: TTestLocalMethod;
131
+ begin
132
+ MyProc := procedure
133
+ begin
134
+ Grains.Square(65);
135
+ end;
136
+
137
+ Assert.WillRaise(MyProc, ERangeError);
138
+ end;
139
+
140
+ procedure TgrainsTests.Test_total_grains;
141
+ var expected: UInt64;
142
+ begin
143
+ expected := 18446744073709551615;
144
+ Assert.AreEqual(expected, Grains.Total);
145
+ end;
146
+
147
+ initialization
148
+ TDUnitX.RegisterTestFixture(TgrainsTests);
149
+ end.