2017-08-15

This commit is contained in:
2017-08-15 10:04:10 -05:00
parent 63b955575a
commit 88b47de8c8
24 changed files with 3100 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
program HelloWorld;
{$IFNDEF TESTINSIGHT}
{$APPTYPE CONSOLE}
{$ENDIF}{$STRONGLINKTYPES ON}
uses
System.SysUtils,
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX,
{$ENDIF }
DUnitX.Loggers.Console,
DUnitX.Loggers.Xml.NUnit,
DUnitX.TestFramework,
uTestHelloWorld in 'uTestHelloWorld.pas',
uHelloWorld in 'uHelloWorld.pas';
var
runner : ITestRunner;
results : IRunResults;
logger : ITestLogger;
nunitLogger : ITestLogger;
begin
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX.RunRegisteredTests;
exit;
{$ENDIF}
try
//Check command line options, will exit if invalid
TDUnitX.CheckCommandLine;
//Create the test runner
runner := TDUnitX.CreateRunner;
//Tell the runner to use RTTI to find Fixtures
runner.UseRTTI := True;
//tell the runner how we will log things
//Log to the console window
logger := TDUnitXConsoleLogger.Create(true);
runner.AddLogger(logger);
//Generate an NUnit compatible XML File
nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
runner.AddLogger(nunitLogger);
runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;
//Run tests
results := runner.Execute;
if not results.AllPassed then
System.ExitCode := EXIT_ERRORS;
{$IFNDEF CI}
//We don't want this happening when running under CI.
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
begin
System.Write('Done.. press <Enter> key to quit.');
System.Readln;
end;
{$ENDIF}
except
on E: Exception do
System.Writeln(E.ClassName, ': ', E.Message);
end;
end.

View File

@@ -0,0 +1,42 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
## Testing
In order to run the tests for this track, you will need to install
DUnitX. Please see the [installation](http://www.exercism.io/languages/delphi/installing) instructions for more information.
### Loading Exercises into Delphi
If Delphi is properly installed, and `*.dpr` file types have been associated with Delphi, then double clicking the supplied `*.dpr` file will start Delphi and load the exercise/project. `control + F9` is the keyboard shortcut to compile the project or pressing `F9` will compile and run the project.
Alternatively you may opt to start Delphi and load your project via. the `File` drop down menu.
### When Questions Come Up
We monitor the [Pascal-Delphi](https://gitter.im/exercism/Pascal-Delphi) support room on [gitter.im](https://gitter.im) to help you with any questions that might arise.
### Submitting Exercises
Note that, when trying to submit an exercise, make sure the exercise file you're submitting is in the `exercism/delphi/<exerciseName>` directory.
For example, if you're submitting `ubob.pas` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/delphi/bob/ubob.pas`.
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@@ -0,0 +1,85 @@
(******************************************************************************
You got an error, which is exactly as it should be.
This is the first step in the Test-Driven Development
(TDD) process.
The most important part of the error is
"cannot compile"
It's looking for a file named uHelloWorld.pas that doesn't exist.
To fix the error, create a unit file named uHelloWorld.pas
in the same directory as the file uTestHelloWorld.pas.
The beginning of the new unit file should contain a unit statement:
unit uHelloWorld;
The new unit should contain Interface, Implementation, and End. statements.
The primary focus of this exercise is to provide you with a very simple
exercise that you can use to test the tools necessary for this language track,
are working correctly. To that end we are providing you with code that you may
use as the solution to this exercise:
{------------------< start solution >------------------}
unit uHelloWorld;
interface
function Hello: string;
implementation
function Hello: string;
begin
result := 'Hello, World!';
end;
end.
{------------------< end solution >------------------}
Hint: Delphi will take care of all this if you instruct it to add a new unit
to your project. Be sure to save the new unit as uHelloWorld.pas before
trying to compile again.
For more guidance as you work on this exercise, see
GETTING_STARTED.md.
******************************************************************************)
unit uTestHelloWorld;
interface
uses
DUnitX.TestFramework;
type
[TestFixture]
HelloWorldTest = class(TObject)
public
[Test]
procedure Say_hi;
end;
implementation
uses uHelloWorld;
procedure HelloWorldTest.Say_hi;
var
Expected: string;
Actual: string;
begin
Expected := 'Hello, World!'; //Expected: This is what is expected to be returned by the function/method (Hello)
Actual := Hello; //Actual: This is what is actually returned by the function/method (Hello)
Assert.AreEqual(Expected, Actual);
//As you progress in this track you will find that not every exercise has Expected and
//Actual defined as explicitly as they have been above. Often times you may find
//that the Expected outcome is inserted as an inline statement and the the call
//to the method being tested will be inserted in the Actual position of AreEqual like so:
//Assert.AreEqual('Hello, World!', Hello);
end;
initialization
TDUnitX.RegisterTestFixture(HelloWorldTest);
end.