trackler 2.2.1.69 → 2.2.1.70
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/isbn-verifier/description.md +25 -20
- data/tracks/c/bin/run-tests +1 -2
- data/tracks/c/exercises/acronym/makefile +10 -0
- data/tracks/c/exercises/all-your-base/makefile +10 -0
- data/tracks/c/exercises/allergies/makefile +10 -0
- data/tracks/c/exercises/anagram/makefile +9 -0
- data/tracks/c/exercises/atbash-cipher/makefile +9 -0
- data/tracks/c/exercises/beer-song/makefile +9 -0
- data/tracks/c/exercises/binary/makefile +9 -0
- data/tracks/c/exercises/binary-search/makefile +9 -0
- data/tracks/c/exercises/bob/makefile +9 -0
- data/tracks/c/exercises/clock/makefile +9 -0
- data/tracks/c/exercises/collatz-conjecture/makefile +10 -0
- data/tracks/c/exercises/difference-of-squares/makefile +9 -0
- data/tracks/c/exercises/gigasecond/makefile +9 -0
- data/tracks/c/exercises/grains/makefile +9 -0
- data/tracks/c/exercises/hamming/makefile +9 -0
- data/tracks/c/exercises/isogram/makefile +10 -0
- data/tracks/c/exercises/largest-series-product/makefile +9 -0
- data/tracks/c/exercises/leap/makefile +9 -0
- data/tracks/c/exercises/meetup/makefile +10 -0
- data/tracks/c/exercises/nth-prime/makefile +9 -0
- data/tracks/c/exercises/nucleotide-count/makefile +10 -0
- data/tracks/c/exercises/palindrome-products/makefile +9 -0
- data/tracks/c/exercises/pangram/makefile +9 -0
- data/tracks/c/exercises/pascals-triangle/makefile +9 -0
- data/tracks/c/exercises/perfect-numbers/makefile +8 -0
- data/tracks/c/exercises/phone-number/makefile +9 -0
- data/tracks/c/exercises/queen-attack/makefile +10 -0
- data/tracks/c/exercises/raindrops/makefile +9 -0
- data/tracks/c/exercises/react/makefile +9 -0
- data/tracks/c/exercises/rna-transcription/makefile +10 -0
- data/tracks/c/exercises/robot-simulator/makefile +9 -0
- data/tracks/c/exercises/roman-numerals/makefile +9 -0
- data/tracks/c/exercises/scrabble-score/makefile +9 -0
- data/tracks/c/exercises/series/makefile +9 -0
- data/tracks/c/exercises/sieve/makefile +10 -0
- data/tracks/c/exercises/space-age/makefile +9 -0
- data/tracks/c/exercises/sublist/makefile +10 -0
- data/tracks/c/exercises/sum-of-multiples/makefile +10 -0
- data/tracks/c/exercises/triangle/makefile +9 -0
- data/tracks/c/exercises/word-count/makefile +9 -0
- data/tracks/delphi/config.json +10 -0
- data/tracks/delphi/exercises/reverse-string/README.md +34 -0
- data/tracks/delphi/exercises/reverse-string/ReverseString.dpr +60 -0
- data/tracks/delphi/exercises/reverse-string/uReverseStringExample.pas +18 -0
- data/tracks/delphi/exercises/reverse-string/uReverseStringTests.pas +69 -0
- data/tracks/fsharp/exercises/forth/Example.fs +29 -25
- data/tracks/fsharp/exercises/forth/ForthTest.fs +190 -74
- data/tracks/fsharp/exercises/markdown/MarkdownTest.fs +6 -3
- data/tracks/fsharp/generators/Exercise.fs +4 -4
- data/tracks/fsharp/generators/Generators.fs +29 -1
- data/tracks/java/exercises/allergies/.meta/src/reference/java/Allergen.java +2 -2
- data/tracks/java/exercises/allergies/.meta/src/reference/java/Allergies.java +4 -4
- data/tracks/java/exercises/allergies/src/main/java/Allergen.java +2 -2
- data/tracks/java/exercises/anagram/.meta/src/reference/java/Anagram.java +5 -5
- data/tracks/java/exercises/bob/.meta/src/reference/java/Bob.java +8 -5
- data/tracks/java/exercises/kindergarten-garden/src/main/java/KindergartenGarden.java +17 -0
- data/tracks/java/exercises/nth-prime/src/main/java/PrimeCalculator.java +7 -0
- data/tracks/java/exercises/rotational-cipher/src/main/java/RotationalCipher.java +11 -0
- data/tracks/javascript/config.json +15 -0
- data/tracks/javascript/exercises/connect/README.md +59 -0
- data/tracks/javascript/exercises/connect/connect.spec.js +108 -0
- data/tracks/javascript/exercises/connect/example.js +105 -0
- data/tracks/kotlin/README.md +1 -1
- data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +2 -2
- metadata +12 -6
- data/tracks/java/exercises/book-store/.meta/src/reference/java/.keep +0 -0
- data/tracks/java/exercises/nth-prime/src/main/java/.keep +0 -0
- data/tracks/java/exercises/rotational-cipher/src/main/java/.keep +0 -0
- data/tracks/javascript/package-lock.json +0 -1895
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,12 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
12
|
+
|
7
13
|
test: tests.out
|
8
14
|
@./tests.out
|
9
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
10
20
|
clean:
|
11
21
|
rm -f *.o *.out
|
12
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,12 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
12
|
+
|
7
13
|
test: tests.out
|
8
14
|
@./tests.out
|
9
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
10
20
|
clean:
|
11
21
|
rm -f *.o *.out
|
12
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,12 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
12
|
+
|
7
13
|
test: tests.out
|
8
14
|
@./tests.out
|
9
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
10
20
|
clean:
|
11
21
|
rm -f *.o *.out
|
12
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,12 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
12
|
+
|
7
13
|
test: tests.out
|
8
14
|
@./tests.out
|
9
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
10
20
|
clean:
|
11
21
|
rm -f *.o *.out
|
12
22
|
|
@@ -1,12 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
12
|
+
|
7
13
|
test: tests.out
|
8
14
|
@./tests.out
|
9
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
10
20
|
clean:
|
11
21
|
rm -f *.o *.out
|
12
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
2
3
|
CFLAGS += -Wall
|
3
4
|
CFLAGS += -Wextra
|
4
5
|
CFLAGS += -pedantic
|
5
6
|
CFLAGS += -Werror
|
6
7
|
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
7
12
|
|
8
13
|
test: tests.out
|
9
14
|
@./tests.out
|
10
15
|
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
11
20
|
clean:
|
12
21
|
rm -f *.o *.out
|
13
22
|
|
data/tracks/delphi/config.json
CHANGED
@@ -22,6 +22,16 @@
|
|
22
22
|
],
|
23
23
|
"uuid": "60eb0882-495d-45f4-8d38-5b10d8851cf6"
|
24
24
|
},
|
25
|
+
{
|
26
|
+
"core": false,
|
27
|
+
"difficulty": 1,
|
28
|
+
"slug": "reverse-string",
|
29
|
+
"topics": [
|
30
|
+
"strings"
|
31
|
+
],
|
32
|
+
"unlocked_by": null,
|
33
|
+
"uuid": "8bdf3796-592c-48f1-b2ef-8e4deb40cc37"
|
34
|
+
},
|
25
35
|
{
|
26
36
|
"core": false,
|
27
37
|
"difficulty": 1,
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# reverse-string
|
2
|
+
|
3
|
+
Reverse a string
|
4
|
+
|
5
|
+
For example:
|
6
|
+
input: "cool"
|
7
|
+
output: "looc"
|
8
|
+
|
9
|
+
## Testing
|
10
|
+
|
11
|
+
In order to run the tests for this track, you will need to install
|
12
|
+
DUnitX. Please see the [installation](http://www.exercism.io/languages/delphi/installing) instructions for more information.
|
13
|
+
|
14
|
+
### Loading Exercises into Delphi
|
15
|
+
|
16
|
+
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.
|
17
|
+
|
18
|
+
Alternatively you may opt to start Delphi and load your project via. the `File` drop down menu.
|
19
|
+
|
20
|
+
### When Questions Come Up
|
21
|
+
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.
|
22
|
+
|
23
|
+
### Submitting Exercises
|
24
|
+
|
25
|
+
Note that, when trying to submit an exercise, make sure the exercise file you're submitting is in the `exercism/delphi/<exerciseName>` directory.
|
26
|
+
|
27
|
+
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`.
|
28
|
+
|
29
|
+
## Source
|
30
|
+
|
31
|
+
Introductory challenge to reverse an input string [https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb](https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb)
|
32
|
+
|
33
|
+
## Submitting Incomplete Solutions
|
34
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,60 @@
|
|
1
|
+
program ReverseString;
|
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
|
+
uReverseStringTests in 'uReverseStringTests.pas',
|
15
|
+
uReverseString in 'uReverseString.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 := True; //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,18 @@
|
|
1
|
+
unit uReverseString;
|
2
|
+
|
3
|
+
interface
|
4
|
+
|
5
|
+
function reverse(aInString: string): string;
|
6
|
+
|
7
|
+
implementation
|
8
|
+
|
9
|
+
function reverse(aInString: string): string;
|
10
|
+
var
|
11
|
+
i: integer;
|
12
|
+
begin
|
13
|
+
result := '';
|
14
|
+
for i := Low(aInString) to High(aInString) do
|
15
|
+
result := aInString[i] + result;
|
16
|
+
end;
|
17
|
+
|
18
|
+
end.
|
@@ -0,0 +1,69 @@
|
|
1
|
+
unit uReverseStringTests;
|
2
|
+
|
3
|
+
interface
|
4
|
+
uses
|
5
|
+
DUnitX.TestFramework;
|
6
|
+
|
7
|
+
const
|
8
|
+
CanonicalVersion = '1.0.1';
|
9
|
+
|
10
|
+
type
|
11
|
+
|
12
|
+
[TestFixture]
|
13
|
+
ReverseStringTest = class(TObject)
|
14
|
+
public
|
15
|
+
[Test]
|
16
|
+
// [Ignore('Comment the "[Ignore]" statement to run the test')]
|
17
|
+
procedure an_empty_string;
|
18
|
+
|
19
|
+
[Test]
|
20
|
+
[Ignore]
|
21
|
+
procedure a_word;
|
22
|
+
|
23
|
+
[Test]
|
24
|
+
[Ignore]
|
25
|
+
procedure a_capitalized_word;
|
26
|
+
|
27
|
+
[Test]
|
28
|
+
[Ignore]
|
29
|
+
procedure a_sentence_with_punctuation;
|
30
|
+
|
31
|
+
[Test]
|
32
|
+
[Ignore]
|
33
|
+
procedure a_palindrome;
|
34
|
+
end;
|
35
|
+
|
36
|
+
implementation
|
37
|
+
uses uReverseString;
|
38
|
+
|
39
|
+
|
40
|
+
{ ReverseStringTest }
|
41
|
+
|
42
|
+
procedure ReverseStringTest.an_empty_string;
|
43
|
+
begin
|
44
|
+
Assert.AreEqual('', reverse(''));
|
45
|
+
end;
|
46
|
+
|
47
|
+
procedure ReverseStringTest.a_capitalized_word;
|
48
|
+
begin
|
49
|
+
Assert.AreEqual('nemaR',reverse('Ramen'));
|
50
|
+
end;
|
51
|
+
|
52
|
+
procedure ReverseStringTest.a_palindrome;
|
53
|
+
begin
|
54
|
+
Assert.AreEqual('racecar',reverse('racecar'));
|
55
|
+
end;
|
56
|
+
|
57
|
+
procedure ReverseStringTest.a_sentence_with_punctuation;
|
58
|
+
begin
|
59
|
+
Assert.AreEqual('!yrgnuh m''I', reverse('I''m hungry!'));
|
60
|
+
end;
|
61
|
+
|
62
|
+
procedure ReverseStringTest.a_word;
|
63
|
+
begin
|
64
|
+
Assert.AreEqual('tobor', reverse('robot'));
|
65
|
+
end;
|
66
|
+
|
67
|
+
initialization
|
68
|
+
TDUnitX.RegisterTestFixture(ReverseStringTest);
|
69
|
+
end.
|
@@ -23,12 +23,6 @@ type Operation =
|
|
23
23
|
|
24
24
|
type ForthState = { sStack: Value list; sInput: Item list; sMapping: Map<Word, Operation> }
|
25
25
|
|
26
|
-
type ForthError =
|
27
|
-
| DivisionByZero
|
28
|
-
| StackUnderflow
|
29
|
-
| InvalidWord
|
30
|
-
| UnknownWord of Word
|
31
|
-
|
32
26
|
let defaultMapping =
|
33
27
|
[("+", Plus);
|
34
28
|
("-", Minus);
|
@@ -72,21 +66,21 @@ let parse text state = parseText text |> addItems state
|
|
72
66
|
|
73
67
|
let unaryStackOp op state =
|
74
68
|
match state.sStack with
|
75
|
-
| [] ->
|
76
|
-
| x::xs ->
|
69
|
+
| [] -> None
|
70
|
+
| x::xs -> Some { state with sStack = op x @ xs}
|
77
71
|
|
78
72
|
let binaryStackOp op state =
|
79
73
|
match state.sStack with
|
80
|
-
| x::y::xs ->
|
81
|
-
| _ ->
|
74
|
+
| x::y::xs -> Some { state with sStack = op x y @ xs}
|
75
|
+
| _ -> None
|
82
76
|
|
83
77
|
let toBinaryStackOp op x y = [op y x]
|
84
78
|
|
85
79
|
let divOp state =
|
86
80
|
match state.sStack with
|
87
|
-
| 0::_ ->
|
88
|
-
| x::y::xs ->
|
89
|
-
| _ ->
|
81
|
+
| 0::_ -> None
|
82
|
+
| x::y::xs -> Some { state with sStack = (y / x) :: xs }
|
83
|
+
| _ -> None
|
90
84
|
|
91
85
|
let applyOp op state =
|
92
86
|
match op with
|
@@ -98,33 +92,43 @@ let applyOp op state =
|
|
98
92
|
| Drop -> unaryStackOp (fun _ -> []) state
|
99
93
|
| Swap -> binaryStackOp (fun x y -> [y; x]) state
|
100
94
|
| Over -> binaryStackOp (fun x y -> [y; x; y]) state
|
101
|
-
| User terms -> addItems state terms |>
|
95
|
+
| User terms -> addItems state terms |> Some
|
102
96
|
|
103
97
|
let evalWord word state =
|
104
98
|
match Map.tryFind word state.sMapping with
|
105
|
-
| None ->
|
99
|
+
| None -> None
|
106
100
|
| Some op -> applyOp op state
|
107
101
|
|
108
102
|
let rec evalState state =
|
109
103
|
match state with
|
110
|
-
|
|
111
|
-
|
|
104
|
+
| None -> state
|
105
|
+
| Some s ->
|
112
106
|
match s.sInput with
|
113
107
|
| [] -> state
|
114
|
-
| (Value v)::xs -> { s with sStack = v::s.sStack; sInput = xs } |>
|
108
|
+
| (Value v)::xs -> { s with sStack = v::s.sStack; sInput = xs } |> Some |> evalState
|
115
109
|
| (Word w)::xs ->
|
116
110
|
match w with
|
117
111
|
| ":" ->
|
118
112
|
match breakBy (fun c -> c = Word ";") xs with
|
119
113
|
| ((Word userWord::operations), remainder) ->
|
120
114
|
{ s with sInput = List.tail remainder; sMapping = Map.add (userWord.ToLower()) (User operations) s.sMapping }
|
121
|
-
|>
|
115
|
+
|> Some
|
122
116
|
|> evalState
|
123
|
-
| _ ->
|
124
|
-
| ";" ->
|
117
|
+
| _ -> None
|
118
|
+
| ";" -> None
|
125
119
|
| _ -> evalWord w { s with sInput = xs } |> evalState
|
126
120
|
|
127
|
-
let eval
|
128
|
-
|
129
|
-
|
130
|
-
|
121
|
+
let rec eval commands (state: ForthState option) =
|
122
|
+
match commands, state with
|
123
|
+
| [], _
|
124
|
+
-> state |> Option.map (fun x -> List.rev x.sStack)
|
125
|
+
| x::xs, Some y ->
|
126
|
+
let updatedState =
|
127
|
+
parse x y
|
128
|
+
|> Some
|
129
|
+
|> evalState
|
130
|
+
|
131
|
+
eval xs updatedState
|
132
|
+
| _ -> None
|
133
|
+
|
134
|
+
let evaluate commands = eval commands (Some empty)
|