trackler 2.0.5.13 → 2.0.5.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/common/.travis.yml +1 -0
  3. data/common/bin/check_required_files_present +55 -0
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/pascal/exercises/Hello-World/TestHelloWorld.dpr +60 -0
  6. data/tracks/pascal/exercises/Hello-World/TestHelloWorld.dproj +176 -0
  7. data/tracks/pascal/exercises/Hello-World/uHelloWorldExample.pas +24 -0
  8. data/tracks/pascal/exercises/Hello-World/uTestHelloWorld.pas +65 -0
  9. data/tracks/pascal/exercises/allergies/AllergyTests.dpr +60 -0
  10. data/tracks/pascal/exercises/allergies/AllergyTests.dproj +176 -0
  11. data/tracks/pascal/exercises/allergies/uAllergiesExample.pas +67 -0
  12. data/tracks/pascal/exercises/allergies/uAllergyTests.pas +177 -0
  13. data/tracks/pascal/exercises/bank-account/BankAccountTests.dpr +60 -0
  14. data/tracks/pascal/exercises/bank-account/BankAccountTests.dproj +176 -0
  15. data/tracks/pascal/exercises/bank-account/uBankAccountExample.pas +96 -0
  16. data/tracks/pascal/exercises/bank-account/uBankAccountTests.pas +140 -0
  17. data/tracks/pascal/exercises/beer-song/BeerSongTests.dpr +60 -0
  18. data/tracks/pascal/exercises/beer-song/BeerSongTests.dproj +176 -0
  19. data/tracks/pascal/exercises/beer-song/uBeerSongExample.pas +45 -0
  20. data/tracks/pascal/exercises/beer-song/uBeerSongTests.pas +84 -0
  21. data/tracks/pascal/exercises/binary-search/BinarySearchTest.dpr +60 -0
  22. data/tracks/pascal/exercises/binary-search/BinarySearchTest.dproj +176 -0
  23. data/tracks/pascal/exercises/binary-search/uBinarySearchExample.pas +40 -0
  24. data/tracks/pascal/exercises/binary-search/uBinarySearchTest.pas +132 -0
  25. data/tracks/pascal/exercises/bob/BobTests.dpr +60 -0
  26. data/tracks/pascal/exercises/bob/BobTests.dproj +176 -0
  27. data/tracks/pascal/exercises/bob/uBobExample.pas +47 -0
  28. data/tracks/pascal/exercises/bob/uBobTests.pas +180 -0
  29. data/tracks/pascal/exercises/book-store/BookStoreTests.dpr +60 -0
  30. data/tracks/pascal/exercises/book-store/BookStoreTests.dproj +176 -0
  31. data/tracks/pascal/exercises/book-store/uBookStoreExample.pas +144 -0
  32. data/tracks/pascal/exercises/book-store/uBookStoreTests.pas +56 -0
  33. data/tracks/pascal/exercises/bowling/BowlingTests.dpr +60 -0
  34. data/tracks/pascal/exercises/bowling/BowlingTests.dproj +176 -0
  35. data/tracks/pascal/exercises/bowling/uBowlingExample.pas +105 -0
  36. data/tracks/pascal/exercises/bowling/uBowlingTests.pas +101 -0
  37. data/tracks/pascal/exercises/circular-buffer/CircularBufferTests.dpr +60 -0
  38. data/tracks/pascal/exercises/circular-buffer/CircularBufferTests.dproj +176 -0
  39. data/tracks/pascal/exercises/circular-buffer/uCircularBufferExample.pas +72 -0
  40. data/tracks/pascal/exercises/circular-buffer/uCircularBufferTests.pas +249 -0
  41. data/tracks/pascal/exercises/clock/ClockTest.dpr +60 -0
  42. data/tracks/pascal/exercises/clock/ClockTest.dproj +176 -0
  43. data/tracks/pascal/exercises/clock/uClockExample.pas +54 -0
  44. data/tracks/pascal/exercises/clock/uClockTest.pas +157 -0
  45. data/tracks/pascal/exercises/etl/ETLtests.dpr +60 -0
  46. data/tracks/pascal/exercises/etl/ETLtests.dproj +176 -0
  47. data/tracks/pascal/exercises/etl/uETLexample.pas +25 -0
  48. data/tracks/pascal/exercises/etl/uETLtests.pas +191 -0
  49. data/tracks/pascal/exercises/hamming/Hamming.dpr +60 -0
  50. data/tracks/pascal/exercises/hamming/Hamming.dproj +176 -0
  51. data/tracks/pascal/exercises/hamming/uHammingExample.pas +24 -0
  52. data/tracks/pascal/exercises/hamming/uHammingTests.pas +165 -0
  53. data/tracks/pascal/exercises/leap/LeapTest.dpr +60 -0
  54. data/tracks/pascal/exercises/leap/LeapTest.dproj +176 -0
  55. data/tracks/pascal/exercises/leap/uLeapExample.pas +17 -0
  56. data/tracks/pascal/exercises/leap/uLeapTests.pas +81 -0
  57. data/tracks/pascal/exercises/nucleotide-count/NucleotideCountTest.dpr +60 -0
  58. data/tracks/pascal/exercises/nucleotide-count/NucleotideCountTest.dproj +176 -0
  59. data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountExample.pas +72 -0
  60. data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountTest.pas +190 -0
  61. data/tracks/pascal/exercises/perfect-numbers/PerfectNumbersTest.dpr +60 -0
  62. data/tracks/pascal/exercises/perfect-numbers/PerfectNumbersTest.dproj +176 -0
  63. data/tracks/pascal/exercises/perfect-numbers/uPerfectNumbersExample.pas +34 -0
  64. data/tracks/pascal/exercises/perfect-numbers/uPerfectNumbersTest.pas +48 -0
  65. data/tracks/pascal/exercises/phone-number/PhoneNumberTests.dpr +60 -0
  66. data/tracks/pascal/exercises/phone-number/PhoneNumberTests.dproj +176 -0
  67. data/tracks/pascal/exercises/phone-number/uPhoneNumberExample.pas +102 -0
  68. data/tracks/pascal/exercises/phone-number/uPhoneNumberTests.pas +138 -0
  69. data/tracks/php/exercises/variable-length-quantity/variable-length-quantity_test.php +1 -1
  70. data/tracks/ruby/Gemfile +0 -1
  71. data/tracks/ruby/Makefile +2 -1
  72. data/tracks/ruby/Rakefile +3 -0
  73. data/tracks/ruby/exercises/simple-linked-list/.meta/.version +1 -0
  74. data/tracks/ruby/exercises/simple-linked-list/example.rb +39 -48
  75. data/tracks/ruby/exercises/simple-linked-list/simple_linked_list_test.rb +99 -125
  76. data/tracks/ruby/exercises/wordy/.meta/.version +1 -0
  77. data/tracks/ruby/exercises/wordy/example.rb +4 -0
  78. data/tracks/ruby/exercises/wordy/example.tt +17 -0
  79. data/tracks/ruby/exercises/wordy/wordy_test.rb +66 -35
  80. data/tracks/ruby/lib/wordy_cases.rb +67 -0
  81. data/tracks/ruby/test/wordy_cases_test.rb +102 -0
  82. data/tracks/scala/config.json +7 -1
  83. data/tracks/scala/exercises/connect/{README.md → HINTS.md} +1 -12
  84. data/tracks/scala/exercises/connect/build.sbt +2 -2
  85. metadata +73 -3
@@ -0,0 +1,56 @@
1
+ unit uBookStoreTests;
2
+
3
+ interface
4
+ uses
5
+ DUnitX.TestFramework;
6
+
7
+ type
8
+ [TestFixture]
9
+ hpTests = class(TObject)
10
+ private
11
+ class function ConvertStrToIntArray(aString: string): TArray<Integer>; static;
12
+ public
13
+ [Test]
14
+ [TestCase('Test total basket price single book', '1, 8.0')]
15
+ // [TestCase('Test total basket Price two of same book', '2|2, 16.0')]
16
+ // [TestCase('Test total basket price empty basket', ', 0.0')]
17
+ // [TestCase('Test basket with two different books', '1|2, 15.2')]
18
+ // [TestCase('Test basket with three different books', '1|2|3, 21.6')]
19
+ // [TestCase('Test basket with four different books', '1|2|3|4, 25.6')]
20
+ // [TestCase('Test basket with five different books', '1|2|3|4|5, 30.0')]
21
+ // [TestCase('Test basket w/2 copies of books 1..3 and one copy of books 4 and 5', '1|1|2|2|3|3|4|5, 51.20')]
22
+ // [TestCase('Test basket w/2 copies of books 1..4 and one copy of book 5', '1|1|2|2|3|3|4|4|5, 55.60')]
23
+ // [TestCase('Test basket w/2 copies of each book', '1|1|2|2|3|3|4|4|5|5, 60.00')]
24
+ // [TestCase('Test basket w/2 copies of each book plus one more copy of book 1', '1|1|2|2|3|3|4|4|5|5|1, 68.00')]
25
+ // [TestCase('Test basket w/2 copies of each book plus one more copy of books 1 and 2', '1|1|2|2|3|3|4|4|5|5|1|2, 75.20')]
26
+ procedure SeveralBasketTestCases(const aBasket: string; const Expected: extended);
27
+ end;
28
+
29
+ implementation
30
+ uses System.SysUtils, uBookStore;
31
+
32
+ const MinDelta = 0.005; //cents
33
+
34
+ class function hpTests.ConvertStrToIntArray(aString: string): TArray<Integer>;
35
+ var splitStr: TArray<string>;
36
+ i: integer;
37
+ begin
38
+ result := nil;
39
+ splitStr := aString.Split(['|']);
40
+ SetLength(result, length(splitStr));
41
+ for i := Low(splitStr) to High(splitStr) do
42
+ result[i] := splitStr[i].ToInteger;
43
+ end;
44
+
45
+ procedure hpTests.SeveralBasketTestCases(const aBasket: string; const Expected: extended);
46
+ var Basket: TArray<integer>;
47
+ fBasket: IBasket;
48
+ begin
49
+ Basket := ConvertStrToIntArray(aBasket);
50
+ fBasket := NewBasket(Basket);
51
+ assert.AreEqual(Expected, FBasket.Total, MinDelta, format('Total should be %0.2f',[Expected]));
52
+ end;
53
+
54
+ initialization
55
+ TDUnitX.RegisterTestFixture(hpTests);
56
+ end.
@@ -0,0 +1,60 @@
1
+ program BowlingTests;
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
+ uBowlingTests in 'uBowlingTests.pas',
15
+ uBowling in 'uBowling.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,176 @@
1
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
+ <PropertyGroup>
3
+ <ProjectGuid>{38C3F5E0-4290-40C1-B4D6-9B84D8309248}</ProjectGuid>
4
+ <ProjectVersion>15.3</ProjectVersion>
5
+ <FrameworkType>None</FrameworkType>
6
+ <MainSource>BowlingTests.dpr</MainSource>
7
+ <Base>True</Base>
8
+ <Config Condition="'$(Config)'==''">Debug</Config>
9
+ <Platform Condition="'$(Platform)'==''">Win32</Platform>
10
+ <TargetedPlatforms>1</TargetedPlatforms>
11
+ <AppType>Console</AppType>
12
+ </PropertyGroup>
13
+ <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
14
+ <Base>true</Base>
15
+ </PropertyGroup>
16
+ <PropertyGroup Condition="('$(Platform)'=='OSX32' and '$(Base)'=='true') or '$(Base_OSX32)'!=''">
17
+ <Base_OSX32>true</Base_OSX32>
18
+ <CfgParent>Base</CfgParent>
19
+ <Base>true</Base>
20
+ </PropertyGroup>
21
+ <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
22
+ <Base_Win32>true</Base_Win32>
23
+ <CfgParent>Base</CfgParent>
24
+ <Base>true</Base>
25
+ </PropertyGroup>
26
+ <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
27
+ <Base_Win64>true</Base_Win64>
28
+ <CfgParent>Base</CfgParent>
29
+ <Base>true</Base>
30
+ </PropertyGroup>
31
+ <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
32
+ <Cfg_1>true</Cfg_1>
33
+ <CfgParent>Base</CfgParent>
34
+ <Base>true</Base>
35
+ </PropertyGroup>
36
+ <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
37
+ <Cfg_1_Win32>true</Cfg_1_Win32>
38
+ <CfgParent>Cfg_1</CfgParent>
39
+ <Cfg_1>true</Cfg_1>
40
+ <Base>true</Base>
41
+ </PropertyGroup>
42
+ <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
43
+ <Cfg_2>true</Cfg_2>
44
+ <CfgParent>Base</CfgParent>
45
+ <Base>true</Base>
46
+ </PropertyGroup>
47
+ <PropertyGroup Condition="'$(Base)'!=''">
48
+ <DCC_UnitSearchPath>$(DUnitX);$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
49
+ <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
50
+ <Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
51
+ <DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
52
+ <DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput>
53
+ <DCC_E>false</DCC_E>
54
+ <DCC_N>false</DCC_N>
55
+ <DCC_S>false</DCC_S>
56
+ <DCC_F>false</DCC_F>
57
+ <DCC_K>false</DCC_K>
58
+ </PropertyGroup>
59
+ <PropertyGroup Condition="'$(Base_OSX32)'!=''">
60
+ <DCC_UsePackage>FireDACASADriver;FireDACSqliteDriver;bindcompfmx;DBXSqliteDriver;FireDACPgDriver;FireDACODBCDriver;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;DBXInterBaseDriver;DataSnapCommon;xmlrtl;ibxpress;DbxCommonDriver;IndyProtocols;dbxcds;DBXMySQLDriver;FireDACCommonDriver;soaprtl;bindengine;bindcompdbx;FMXTee;fmxFireDAC;FireDACADSDriver;CustomIPTransport;FireDAC;dsnap;IndyIPServer;fmxase;IndyCore;IndyIPCommon;CloudService;FireDACIBDriver;FmxTeeUI;inet;fmxobj;FireDACMySQLDriver;inetdbxpress;fmxdae;RESTComponents;FireDACMSAccDriver;dbexpress;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
61
+ </PropertyGroup>
62
+ <PropertyGroup Condition="'$(Base_Win32)'!=''">
63
+ <DCC_UsePackage>frxDB19;L208_r140;FireDACASADriver;FireDACSqliteDriver;bindcompfmx;DBXSqliteDriver;AbbreviaVCL;vcldbx;FireDACPgDriver;FireDACODBCDriver;S404_r;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;TeeDB;frx19;vclib;inetdbbde;DBXInterBaseDriver;Tee;DataSnapCommon;vclFireDAC;Rave110VCL;xmlrtl;svnui;ibxpress;DbxCommonDriver;vclimg;IndyProtocols;dbxcds;DBXMySQLDriver;FireDACCommonDriver;MetropolisUILiveTile;O408_r;soaprtl;bindengine;vclactnband;vcldb;bindcompdbx;vcldsnap;bindcompvcl;FMXTee;TeeUI;AsyncPro;vclie;XMLPartner_PR;fmxFireDAC;FireDACADSDriver;vcltouch;CustomIPTransport;G114_R140;vclribbon;VclSmp;FireDAC;dsnap;IndyIPServer;Intraweb;fmxase;vcl;IndyCore;VCLRESTComponents;OmniThreadLibraryRuntimeXE5;IndyIPCommon;CloudService;CodeSiteExpressPkg;dsnapcon;FireDACIBDriver;FmxTeeUI;inet;fmxobj;E111_R120;FireDACMySQLDriver;vclx;inetdbxpress;svn;fmxdae;frxe19;RESTComponents;bdertl;FireDACMSAccDriver;adortl;dbexpress;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
64
+ <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
65
+ <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
66
+ <VerInfo_Locale>1033</VerInfo_Locale>
67
+ </PropertyGroup>
68
+ <PropertyGroup Condition="'$(Base_Win64)'!=''">
69
+ <DCC_UsePackage>FireDACASADriver;FireDACSqliteDriver;bindcompfmx;DBXSqliteDriver;AbbreviaVCL;FireDACPgDriver;FireDACODBCDriver;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;TeeDB;vclib;DBXInterBaseDriver;Tee;DataSnapCommon;vclFireDAC;xmlrtl;ibxpress;DbxCommonDriver;vclimg;IndyProtocols;dbxcds;DBXMySQLDriver;FireDACCommonDriver;MetropolisUILiveTile;O408_r;soaprtl;bindengine;vclactnband;vcldb;bindcompdbx;vcldsnap;bindcompvcl;FMXTee;TeeUI;vclie;fmxFireDAC;FireDACADSDriver;vcltouch;CustomIPTransport;vclribbon;VclSmp;FireDAC;dsnap;IndyIPServer;Intraweb;fmxase;vcl;IndyCore;VCLRESTComponents;IndyIPCommon;CloudService;dsnapcon;FireDACIBDriver;FmxTeeUI;inet;fmxobj;FireDACMySQLDriver;vclx;inetdbxpress;fmxdae;RESTComponents;FireDACMSAccDriver;adortl;dbexpress;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
70
+ </PropertyGroup>
71
+ <PropertyGroup Condition="'$(Cfg_1)'!=''">
72
+ <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
73
+ <DCC_DebugDCUs>true</DCC_DebugDCUs>
74
+ <DCC_Optimize>false</DCC_Optimize>
75
+ <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
76
+ <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
77
+ <DCC_RemoteDebug>true</DCC_RemoteDebug>
78
+ </PropertyGroup>
79
+ <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
80
+ <DCC_RemoteDebug>false</DCC_RemoteDebug>
81
+ </PropertyGroup>
82
+ <PropertyGroup Condition="'$(Cfg_2)'!=''">
83
+ <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
84
+ <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
85
+ <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
86
+ <DCC_DebugInformation>0</DCC_DebugInformation>
87
+ </PropertyGroup>
88
+ <ItemGroup>
89
+ <DelphiCompile Include="$(MainSource)">
90
+ <MainSource>MainSource</MainSource>
91
+ </DelphiCompile>
92
+ <DCCReference Include="uBowlingTests.pas"/>
93
+ <DCCReference Include="uBowling.pas"/>
94
+ <BuildConfiguration Include="Release">
95
+ <Key>Cfg_2</Key>
96
+ <CfgParent>Base</CfgParent>
97
+ </BuildConfiguration>
98
+ <BuildConfiguration Include="Base">
99
+ <Key>Base</Key>
100
+ </BuildConfiguration>
101
+ <BuildConfiguration Include="Debug">
102
+ <Key>Cfg_1</Key>
103
+ <CfgParent>Base</CfgParent>
104
+ </BuildConfiguration>
105
+ </ItemGroup>
106
+ <ProjectExtensions>
107
+ <Borland.Personality>Delphi.Personality.12</Borland.Personality>
108
+ <Borland.ProjectType/>
109
+ <BorlandProject>
110
+ <Delphi.Personality>
111
+ <VersionInfo>
112
+ <VersionInfo Name="IncludeVerInfo">False</VersionInfo>
113
+ <VersionInfo Name="AutoIncBuild">False</VersionInfo>
114
+ <VersionInfo Name="MajorVer">1</VersionInfo>
115
+ <VersionInfo Name="MinorVer">0</VersionInfo>
116
+ <VersionInfo Name="Release">0</VersionInfo>
117
+ <VersionInfo Name="Build">0</VersionInfo>
118
+ <VersionInfo Name="Debug">False</VersionInfo>
119
+ <VersionInfo Name="PreRelease">False</VersionInfo>
120
+ <VersionInfo Name="Special">False</VersionInfo>
121
+ <VersionInfo Name="Private">False</VersionInfo>
122
+ <VersionInfo Name="DLL">False</VersionInfo>
123
+ <VersionInfo Name="Locale">1033</VersionInfo>
124
+ <VersionInfo Name="CodePage">1252</VersionInfo>
125
+ </VersionInfo>
126
+ <VersionInfoKeys>
127
+ <VersionInfoKeys Name="CompanyName"/>
128
+ <VersionInfoKeys Name="FileDescription"/>
129
+ <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
130
+ <VersionInfoKeys Name="InternalName"/>
131
+ <VersionInfoKeys Name="LegalCopyright"/>
132
+ <VersionInfoKeys Name="LegalTrademarks"/>
133
+ <VersionInfoKeys Name="OriginalFilename"/>
134
+ <VersionInfoKeys Name="ProductName"/>
135
+ <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
136
+ <VersionInfoKeys Name="Comments"/>
137
+ <VersionInfoKeys Name="CFBundleName"/>
138
+ <VersionInfoKeys Name="CFBundleDisplayName"/>
139
+ <VersionInfoKeys Name="UIDeviceFamily"/>
140
+ <VersionInfoKeys Name="CFBundleIdentifier"/>
141
+ <VersionInfoKeys Name="CFBundleVersion"/>
142
+ <VersionInfoKeys Name="CFBundlePackageType"/>
143
+ <VersionInfoKeys Name="CFBundleSignature"/>
144
+ <VersionInfoKeys Name="CFBundleAllowMixedLocalizations"/>
145
+ <VersionInfoKeys Name="UISupportedInterfaceOrientations"/>
146
+ <VersionInfoKeys Name="CFBundleExecutable"/>
147
+ <VersionInfoKeys Name="CFBundleResourceSpecification"/>
148
+ <VersionInfoKeys Name="LSRequiresIPhoneOS"/>
149
+ <VersionInfoKeys Name="CFBundleInfoDictionaryVersion"/>
150
+ <VersionInfoKeys Name="CFBundleDevelopmentRegion"/>
151
+ <VersionInfoKeys Name="package"/>
152
+ <VersionInfoKeys Name="label"/>
153
+ <VersionInfoKeys Name="versionCode"/>
154
+ <VersionInfoKeys Name="versionName"/>
155
+ <VersionInfoKeys Name="persistent"/>
156
+ <VersionInfoKeys Name="restoreAnyVersion"/>
157
+ <VersionInfoKeys Name="installLocation"/>
158
+ <VersionInfoKeys Name="largeHeap"/>
159
+ <VersionInfoKeys Name="theme"/>
160
+ </VersionInfoKeys>
161
+ <Source>
162
+ <Source Name="MainSource">BowlingTests.dpr</Source>
163
+ </Source>
164
+ </Delphi.Personality>
165
+ <Deployment/>
166
+ <Platforms>
167
+ <Platform value="OSX32">False</Platform>
168
+ <Platform value="Win32">True</Platform>
169
+ <Platform value="Win64">False</Platform>
170
+ </Platforms>
171
+ </BorlandProject>
172
+ <ProjectFileVersion>12</ProjectFileVersion>
173
+ </ProjectExtensions>
174
+ <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
175
+ <Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
176
+ </Project>
@@ -0,0 +1,105 @@
1
+ unit uBowling;
2
+
3
+ interface
4
+ uses System.Generics.Collections;
5
+
6
+ type
7
+ IBowlingGame = interface(IInvokable)
8
+ ['{D4A292B6-BC15-48ED-AE04-2D34759017CB}']
9
+ procedure Roll(aPins: integer);
10
+ function Score: integer;
11
+ end;
12
+
13
+ function NewBowlingGame: IBowlingGame;
14
+
15
+ implementation
16
+
17
+ type
18
+ TBowlingGame = class(TInterfacedObject, IBowlingGame)
19
+ private
20
+ fRolls: TList<integer>;
21
+ fNumberOfFrames: integer;
22
+ fMaximumFrameScore: integer;
23
+ function IsStrike(aFrameIndex: integer): Boolean;
24
+ function IsSpare(aFrameIndex: integer): Boolean;
25
+ function StrikeBonus(aFrameIndex: integer): integer;
26
+ function SpareBonus(aFrameIndex: integer): integer;
27
+ function SumOfPinsInFrame(aFrameIndex: integer): integer;
28
+ public
29
+ constructor create;
30
+ function Score: integer;
31
+ procedure Roll(aPins: integer);
32
+ end;
33
+
34
+ function NewBowlingGame: IBowlingGame;
35
+ begin
36
+ result := TBowlingGame.create;
37
+ end;
38
+
39
+ constructor TBowlingGame.create;
40
+ begin
41
+ fNumberOfFrames := 10;
42
+ fMaximumFrameScore := 10;
43
+ fRolls := TList<integer>.Create;
44
+ end;
45
+
46
+ procedure TBowlingGame.Roll(aPins: Integer);
47
+ begin
48
+ fRolls.Add(aPins);
49
+ end;
50
+
51
+ function TBowlingGame.Score: integer;
52
+ var lFrameIndex: integer;
53
+ i: integer;
54
+ lScore: integer;
55
+ begin
56
+ lScore := 0;
57
+ lFrameIndex := 0;
58
+ for i := 0 to fNumberOfFrames - 1 do
59
+ begin
60
+ if IsStrike(lFrameIndex) then
61
+ begin
62
+ lScore := lScore + 10 + StrikeBonus(lFrameIndex);
63
+ inc(lFrameIndex);
64
+ end
65
+ else
66
+ if IsSpare(lFrameIndex) then
67
+ begin
68
+ lScore := lScore + 10 + SpareBonus(lFrameIndex);
69
+ inc(lFrameIndex, 2);
70
+ end
71
+ else
72
+ begin
73
+ lScore := lScore + SumOfPinsInFrame(lFrameIndex);
74
+ inc(lFrameIndex, 2);
75
+ end;
76
+ end;
77
+ result := lScore;
78
+ end;
79
+
80
+ function TBowlingGame.IsStrike(aFrameIndex: Integer): Boolean;
81
+ begin
82
+ result := fRolls[aFrameIndex] = fMaximumFrameScore;
83
+ end;
84
+
85
+ function TBowlingGame.IsSpare(aFrameIndex: Integer): Boolean;
86
+ begin
87
+ result := fRolls[aFrameIndex] + fRolls[aFrameIndex + 1] = FMaximumFrameScore;
88
+ end;
89
+
90
+ function TBowlingGame.StrikeBonus(aFrameIndex: Integer): integer;
91
+ begin
92
+ result := fRolls[aFrameIndex + 1] + fRolls[aFrameIndex + 2];
93
+ end;
94
+
95
+ function TBowlingGame.SpareBonus(aFrameIndex: Integer): integer;
96
+ begin
97
+ result := fRolls[aFrameIndex + 2];
98
+ end;
99
+
100
+ function TBowlingGame.SumOfPinsInFrame(aFrameIndex: Integer): integer;
101
+ begin
102
+ result := fRolls[aFrameIndex] + fRolls[aFrameIndex + 1];
103
+ end;
104
+
105
+ end.
@@ -0,0 +1,101 @@
1
+ unit uBowlingTests;
2
+
3
+ interface
4
+ uses
5
+ DUnitX.TestFramework,
6
+ uBowling;
7
+
8
+ type
9
+
10
+ [TestFixture]
11
+ BowlingTests = class(TObject)
12
+ private
13
+ class procedure RollMany(pins: integer; count: integer; game: IBowlingGame); static;
14
+ class procedure RollSpare(game: IBowlingGame); static;
15
+ class procedure RollStrike(game: IBowlingGame); static;
16
+ public
17
+ [Test]
18
+ [Ignore]
19
+ procedure Gutter_game;
20
+ [Test]
21
+ [Ignore]
22
+ procedure All_ones_game;
23
+ [Test]
24
+ [Ignore]
25
+ procedure One_spare_game;
26
+ [Test]
27
+ [Ignore]
28
+ procedure One_strike_game;
29
+ [Test]
30
+ [Ignore]
31
+ procedure Perfect_game;
32
+ end;
33
+
34
+ implementation
35
+
36
+ procedure BowlingTests.Gutter_game;
37
+ var game: IBowlingGame;
38
+ begin
39
+ game := NewBowlingGame;
40
+ RollMany(0,20,game);
41
+ assert.AreEqual(0,game.Score);
42
+ end;
43
+
44
+ procedure BowlingTests.All_ones_game;
45
+ var game: IBowlingGame;
46
+ begin
47
+ game := NewBowlingGame;
48
+ RollMany(1, 20, game);
49
+ assert.AreEqual(20,game.Score);
50
+ end;
51
+
52
+ procedure BowlingTests.One_spare_game;
53
+ var game: IBowlingGame;
54
+ begin
55
+ game := NewBowlingGame;
56
+ RollSpare(game);
57
+ game.Roll(3);
58
+ RollMany(0, 17, game);
59
+ assert.AreEqual(16, game.Score);
60
+ end;
61
+
62
+ procedure BowlingTests.One_strike_game;
63
+ var game: IBowlingGame;
64
+ begin
65
+ game := NewBowlingGame;
66
+ RollStrike(game);
67
+ game.Roll(3);
68
+ game.Roll(4);
69
+ RollMany(0, 16, game);
70
+ assert.AreEqual(24, game.Score);
71
+ end;
72
+
73
+ procedure BowlingTests.Perfect_game;
74
+ var game: IBowlingGame;
75
+ begin
76
+ game := NewBowlingGame;
77
+ RollMany(10, 12, game);
78
+ assert.AreEqual(300, Game.Score);
79
+ end;
80
+
81
+ class procedure BowlingTests.RollMany(pins: integer; count: integer; game: IBowlingGame);
82
+ var i: integer;
83
+ begin
84
+ for i := 0 to count - 1 do
85
+ game.Roll(pins);
86
+ end;
87
+
88
+ class procedure BowlingTests.RollSpare(game: IBowlingGame);
89
+ begin
90
+ game.Roll(5);
91
+ game.Roll(5);
92
+ end;
93
+
94
+ class procedure BowlingTests.RollStrike(game: IBowlingGame);
95
+ begin
96
+ game.Roll(10);
97
+ end;
98
+
99
+ initialization
100
+ TDUnitX.RegisterTestFixture(BowlingTests);
101
+ end.