trackler 2.2.1.96 → 2.2.1.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/fsharp/exercises/bowling/BowlingTest.fs +77 -42
- data/tracks/fsharp/generators/Generators.fs +24 -0
- data/tracks/go/exercises/acronym/cases_test.go +2 -6
- data/tracks/go/exercises/anagram/cases_test.go +2 -40
- data/tracks/go/exercises/hamming/.meta/gen.go +7 -5
- data/tracks/go/exercises/hamming/cases_test.go +2 -2
- data/tracks/go/exercises/largest-series-product/.meta/gen.go +6 -4
- data/tracks/go/exercises/largest-series-product/cases_test.go +2 -2
- data/tracks/go/exercises/leap/.meta/gen.go +5 -3
- data/tracks/go/exercises/leap/cases_test.go +2 -2
- data/tracks/go/exercises/nth-prime/.meta/gen.go +5 -3
- data/tracks/go/exercises/nth-prime/cases_test.go +2 -2
- data/tracks/java/exercises/allergies/.meta/hints.md +58 -0
- data/tracks/java/exercises/allergies/README.md +62 -0
- data/tracks/java/exercises/atbash-cipher/.meta/hints.md +58 -0
- data/tracks/java/exercises/atbash-cipher/README.md +62 -0
- data/tracks/java/exercises/bob/.meta/hints.md +58 -0
- data/tracks/java/exercises/bob/README.md +62 -0
- data/tracks/java/exercises/bracket-push/.meta/hints.md +58 -0
- data/tracks/java/exercises/bracket-push/README.md +62 -0
- data/tracks/java/exercises/hello-world/.meta/version +1 -0
- data/tracks/java/exercises/pascals-triangle/.meta/hints.md +58 -0
- data/tracks/java/exercises/pascals-triangle/README.md +62 -0
- data/tracks/java/exercises/series/.meta/hints.md +58 -0
- data/tracks/java/exercises/series/README.md +62 -0
- data/tracks/python/exercises/grep/grep_test.py +142 -79
- data/tracks/python/exercises/house/example.py +3 -3
- data/tracks/python/exercises/house/house.py +1 -1
- data/tracks/python/exercises/luhn/example.py +4 -4
- data/tracks/python/exercises/luhn/luhn.py +1 -1
- metadata +9 -2
@@ -1,8 +1,8 @@
|
|
1
1
|
package leap
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 1.
|
4
|
+
// Commit: e348053 leap: Apply new "input" policy
|
5
|
+
// Problem Specifications Version: 1.3.0
|
6
6
|
|
7
7
|
var testCases = []struct {
|
8
8
|
year int
|
@@ -20,8 +20,10 @@ func main() {
|
|
20
20
|
|
21
21
|
type OneCase struct {
|
22
22
|
Description string
|
23
|
-
Input
|
24
|
-
|
23
|
+
Input struct {
|
24
|
+
Number int
|
25
|
+
}
|
26
|
+
Expected interface{}
|
25
27
|
}
|
26
28
|
|
27
29
|
// The JSON structure we expect to be able to unmarshal into
|
@@ -63,7 +65,7 @@ var tests = []struct {
|
|
63
65
|
}{
|
64
66
|
{{range .J.Cases}}{
|
65
67
|
"{{.Description}}",
|
66
|
-
{{.Input}},
|
68
|
+
{{.Input.Number}},
|
67
69
|
{{- if .HasPrimeAnswer}}
|
68
70
|
{{.PrimeAnswer}},
|
69
71
|
true,
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package prime
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 2.
|
4
|
+
// Commit: 4a3ba76 nth-prime: Apply new "input" policy
|
5
|
+
// Problem Specifications Version: 2.1.0
|
6
6
|
|
7
7
|
var tests = []struct {
|
8
8
|
description string
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
2
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
3
|
+
It does mean that when you first try to run the tests, they won't compile.
|
4
|
+
They will give you an error similar to:
|
5
|
+
```
|
6
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
7
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
8
|
+
^
|
9
|
+
symbol: class ExerciseClassName
|
10
|
+
location: class ExerciseClassNameTest
|
11
|
+
```
|
12
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
13
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
14
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
15
|
+
|
16
|
+
When you try to run the tests again you will get slightly different errors.
|
17
|
+
You might get an error similar to:
|
18
|
+
```
|
19
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
20
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
21
|
+
^
|
22
|
+
required: no arguments
|
23
|
+
found: String
|
24
|
+
reason: actual and formal argument lists differ in length
|
25
|
+
```
|
26
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
27
|
+
If you don't add a constructor, Java will add a default one for you.
|
28
|
+
This default constructor takes no arguments.
|
29
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
30
|
+
In the example above you could add:
|
31
|
+
```
|
32
|
+
ExerciseClassName(String input) {
|
33
|
+
|
34
|
+
}
|
35
|
+
```
|
36
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
37
|
+
|
38
|
+
You might also get an error similar to:
|
39
|
+
```
|
40
|
+
error: cannot find symbol
|
41
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
42
|
+
^
|
43
|
+
symbol: method someMethod()
|
44
|
+
location: variable exerciseClassName of type ExerciseClassName
|
45
|
+
```
|
46
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
47
|
+
In the example above you would add:
|
48
|
+
```
|
49
|
+
String someMethod() {
|
50
|
+
return "";
|
51
|
+
}
|
52
|
+
```
|
53
|
+
Make sure the return type matches what the test is expecting.
|
54
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
55
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
56
|
+
The new error should tell you which type it's expecting.
|
57
|
+
|
58
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
@@ -29,6 +29,68 @@ allergens that score 256, 512, 1024, etc.). Your program should
|
|
29
29
|
ignore those components of the score. For example, if the allergy
|
30
30
|
score is 257, your program should only report the eggs (1) allergy.
|
31
31
|
|
32
|
+
# Java Tips
|
33
|
+
|
34
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
35
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
36
|
+
It does mean that when you first try to run the tests, they won't compile.
|
37
|
+
They will give you an error similar to:
|
38
|
+
```
|
39
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
40
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
41
|
+
^
|
42
|
+
symbol: class ExerciseClassName
|
43
|
+
location: class ExerciseClassNameTest
|
44
|
+
```
|
45
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
46
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
47
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
48
|
+
|
49
|
+
When you try to run the tests again you will get slightly different errors.
|
50
|
+
You might get an error similar to:
|
51
|
+
```
|
52
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
53
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
54
|
+
^
|
55
|
+
required: no arguments
|
56
|
+
found: String
|
57
|
+
reason: actual and formal argument lists differ in length
|
58
|
+
```
|
59
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
60
|
+
If you don't add a constructor, Java will add a default one for you.
|
61
|
+
This default constructor takes no arguments.
|
62
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
63
|
+
In the example above you could add:
|
64
|
+
```
|
65
|
+
ExerciseClassName(String input) {
|
66
|
+
|
67
|
+
}
|
68
|
+
```
|
69
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
70
|
+
|
71
|
+
You might also get an error similar to:
|
72
|
+
```
|
73
|
+
error: cannot find symbol
|
74
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
75
|
+
^
|
76
|
+
symbol: method someMethod()
|
77
|
+
location: variable exerciseClassName of type ExerciseClassName
|
78
|
+
```
|
79
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
80
|
+
In the example above you would add:
|
81
|
+
```
|
82
|
+
String someMethod() {
|
83
|
+
return "";
|
84
|
+
}
|
85
|
+
```
|
86
|
+
Make sure the return type matches what the test is expecting.
|
87
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
88
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
89
|
+
The new error should tell you which type it's expecting.
|
90
|
+
|
91
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
92
|
+
|
93
|
+
|
32
94
|
# Running the tests
|
33
95
|
|
34
96
|
You can run all the tests for an exercise by entering
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
2
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
3
|
+
It does mean that when you first try to run the tests, they won't compile.
|
4
|
+
They will give you an error similar to:
|
5
|
+
```
|
6
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
7
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
8
|
+
^
|
9
|
+
symbol: class ExerciseClassName
|
10
|
+
location: class ExerciseClassNameTest
|
11
|
+
```
|
12
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
13
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
14
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
15
|
+
|
16
|
+
When you try to run the tests again you will get slightly different errors.
|
17
|
+
You might get an error similar to:
|
18
|
+
```
|
19
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
20
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
21
|
+
^
|
22
|
+
required: no arguments
|
23
|
+
found: String
|
24
|
+
reason: actual and formal argument lists differ in length
|
25
|
+
```
|
26
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
27
|
+
If you don't add a constructor, Java will add a default one for you.
|
28
|
+
This default constructor takes no arguments.
|
29
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
30
|
+
In the example above you could add:
|
31
|
+
```
|
32
|
+
ExerciseClassName(String input) {
|
33
|
+
|
34
|
+
}
|
35
|
+
```
|
36
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
37
|
+
|
38
|
+
You might also get an error similar to:
|
39
|
+
```
|
40
|
+
error: cannot find symbol
|
41
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
42
|
+
^
|
43
|
+
symbol: method someMethod()
|
44
|
+
location: variable exerciseClassName of type ExerciseClassName
|
45
|
+
```
|
46
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
47
|
+
In the example above you would add:
|
48
|
+
```
|
49
|
+
String someMethod() {
|
50
|
+
return "";
|
51
|
+
}
|
52
|
+
```
|
53
|
+
Make sure the return type matches what the test is expecting.
|
54
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
55
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
56
|
+
The new error should tell you which type it's expecting.
|
57
|
+
|
58
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
@@ -28,6 +28,68 @@ things based on word boundaries.
|
|
28
28
|
- Decoding `gvhg` gives `test`
|
29
29
|
- Decoding `gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt` gives `thequickbrownfoxjumpsoverthelazydog`
|
30
30
|
|
31
|
+
# Java Tips
|
32
|
+
|
33
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
34
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
35
|
+
It does mean that when you first try to run the tests, they won't compile.
|
36
|
+
They will give you an error similar to:
|
37
|
+
```
|
38
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
39
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
40
|
+
^
|
41
|
+
symbol: class ExerciseClassName
|
42
|
+
location: class ExerciseClassNameTest
|
43
|
+
```
|
44
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
45
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
46
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
47
|
+
|
48
|
+
When you try to run the tests again you will get slightly different errors.
|
49
|
+
You might get an error similar to:
|
50
|
+
```
|
51
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
52
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
53
|
+
^
|
54
|
+
required: no arguments
|
55
|
+
found: String
|
56
|
+
reason: actual and formal argument lists differ in length
|
57
|
+
```
|
58
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
59
|
+
If you don't add a constructor, Java will add a default one for you.
|
60
|
+
This default constructor takes no arguments.
|
61
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
62
|
+
In the example above you could add:
|
63
|
+
```
|
64
|
+
ExerciseClassName(String input) {
|
65
|
+
|
66
|
+
}
|
67
|
+
```
|
68
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
69
|
+
|
70
|
+
You might also get an error similar to:
|
71
|
+
```
|
72
|
+
error: cannot find symbol
|
73
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
74
|
+
^
|
75
|
+
symbol: method someMethod()
|
76
|
+
location: variable exerciseClassName of type ExerciseClassName
|
77
|
+
```
|
78
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
79
|
+
In the example above you would add:
|
80
|
+
```
|
81
|
+
String someMethod() {
|
82
|
+
return "";
|
83
|
+
}
|
84
|
+
```
|
85
|
+
Make sure the return type matches what the test is expecting.
|
86
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
87
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
88
|
+
The new error should tell you which type it's expecting.
|
89
|
+
|
90
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
91
|
+
|
92
|
+
|
31
93
|
# Running the tests
|
32
94
|
|
33
95
|
You can run all the tests for an exercise by entering
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
2
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
3
|
+
It does mean that when you first try to run the tests, they won't compile.
|
4
|
+
They will give you an error similar to:
|
5
|
+
```
|
6
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
7
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
8
|
+
^
|
9
|
+
symbol: class ExerciseClassName
|
10
|
+
location: class ExerciseClassNameTest
|
11
|
+
```
|
12
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
13
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
14
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
15
|
+
|
16
|
+
When you try to run the tests again you will get slightly different errors.
|
17
|
+
You might get an error similar to:
|
18
|
+
```
|
19
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
20
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
21
|
+
^
|
22
|
+
required: no arguments
|
23
|
+
found: String
|
24
|
+
reason: actual and formal argument lists differ in length
|
25
|
+
```
|
26
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
27
|
+
If you don't add a constructor, Java will add a default one for you.
|
28
|
+
This default constructor takes no arguments.
|
29
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
30
|
+
In the example above you could add:
|
31
|
+
```
|
32
|
+
ExerciseClassName(String input) {
|
33
|
+
|
34
|
+
}
|
35
|
+
```
|
36
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
37
|
+
|
38
|
+
You might also get an error similar to:
|
39
|
+
```
|
40
|
+
error: cannot find symbol
|
41
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
42
|
+
^
|
43
|
+
symbol: method someMethod()
|
44
|
+
location: variable exerciseClassName of type ExerciseClassName
|
45
|
+
```
|
46
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
47
|
+
In the example above you would add:
|
48
|
+
```
|
49
|
+
String someMethod() {
|
50
|
+
return "";
|
51
|
+
}
|
52
|
+
```
|
53
|
+
Make sure the return type matches what the test is expecting.
|
54
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
55
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
56
|
+
The new error should tell you which type it's expecting.
|
57
|
+
|
58
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
@@ -13,6 +13,68 @@ anything.
|
|
13
13
|
|
14
14
|
He answers 'Whatever.' to anything else.
|
15
15
|
|
16
|
+
# Java Tips
|
17
|
+
|
18
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
19
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
20
|
+
It does mean that when you first try to run the tests, they won't compile.
|
21
|
+
They will give you an error similar to:
|
22
|
+
```
|
23
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
24
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
25
|
+
^
|
26
|
+
symbol: class ExerciseClassName
|
27
|
+
location: class ExerciseClassNameTest
|
28
|
+
```
|
29
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
30
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
31
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
32
|
+
|
33
|
+
When you try to run the tests again you will get slightly different errors.
|
34
|
+
You might get an error similar to:
|
35
|
+
```
|
36
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
37
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
38
|
+
^
|
39
|
+
required: no arguments
|
40
|
+
found: String
|
41
|
+
reason: actual and formal argument lists differ in length
|
42
|
+
```
|
43
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
44
|
+
If you don't add a constructor, Java will add a default one for you.
|
45
|
+
This default constructor takes no arguments.
|
46
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
47
|
+
In the example above you could add:
|
48
|
+
```
|
49
|
+
ExerciseClassName(String input) {
|
50
|
+
|
51
|
+
}
|
52
|
+
```
|
53
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
54
|
+
|
55
|
+
You might also get an error similar to:
|
56
|
+
```
|
57
|
+
error: cannot find symbol
|
58
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
59
|
+
^
|
60
|
+
symbol: method someMethod()
|
61
|
+
location: variable exerciseClassName of type ExerciseClassName
|
62
|
+
```
|
63
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
64
|
+
In the example above you would add:
|
65
|
+
```
|
66
|
+
String someMethod() {
|
67
|
+
return "";
|
68
|
+
}
|
69
|
+
```
|
70
|
+
Make sure the return type matches what the test is expecting.
|
71
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
72
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
73
|
+
The new error should tell you which type it's expecting.
|
74
|
+
|
75
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
76
|
+
|
77
|
+
|
16
78
|
# Running the tests
|
17
79
|
|
18
80
|
You can run all the tests for an exercise by entering
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
2
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
3
|
+
It does mean that when you first try to run the tests, they won't compile.
|
4
|
+
They will give you an error similar to:
|
5
|
+
```
|
6
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
7
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
8
|
+
^
|
9
|
+
symbol: class ExerciseClassName
|
10
|
+
location: class ExerciseClassNameTest
|
11
|
+
```
|
12
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
13
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
14
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
15
|
+
|
16
|
+
When you try to run the tests again you will get slightly different errors.
|
17
|
+
You might get an error similar to:
|
18
|
+
```
|
19
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
20
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
21
|
+
^
|
22
|
+
required: no arguments
|
23
|
+
found: String
|
24
|
+
reason: actual and formal argument lists differ in length
|
25
|
+
```
|
26
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
27
|
+
If you don't add a constructor, Java will add a default one for you.
|
28
|
+
This default constructor takes no arguments.
|
29
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
30
|
+
In the example above you could add:
|
31
|
+
```
|
32
|
+
ExerciseClassName(String input) {
|
33
|
+
|
34
|
+
}
|
35
|
+
```
|
36
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
37
|
+
|
38
|
+
You might also get an error similar to:
|
39
|
+
```
|
40
|
+
error: cannot find symbol
|
41
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
42
|
+
^
|
43
|
+
symbol: method someMethod()
|
44
|
+
location: variable exerciseClassName of type ExerciseClassName
|
45
|
+
```
|
46
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
47
|
+
In the example above you would add:
|
48
|
+
```
|
49
|
+
String someMethod() {
|
50
|
+
return "";
|
51
|
+
}
|
52
|
+
```
|
53
|
+
Make sure the return type matches what the test is expecting.
|
54
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
55
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
56
|
+
The new error should tell you which type it's expecting.
|
57
|
+
|
58
|
+
After having resolved these errors you should be ready to start making the tests pass!
|