-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/bug/857-cached-link' into bug/85…
…7-cached-link
- Loading branch information
Showing
24 changed files
with
809 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
common-content/en/module/js1/identifying-missing-tests/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
+++ | ||
title = '🔬 Identifying missing tests' | ||
|
||
time = 30 | ||
facilitation = false | ||
emoji= '🔬' | ||
[objectives] | ||
1='Define groups of input' | ||
2='Define edge cases' | ||
3='Identify groups of input for a function' | ||
4='Identify edge cases for a function' | ||
[build] | ||
render = 'never' | ||
list = 'local' | ||
publishResources = false | ||
|
||
+++ | ||
|
||
We started off writing one test for our code - checking that it correctly handled the input `08:00`. We wrote an implementation that passed all our (1) tests! | ||
|
||
Then we realised there was a bug - it didn't handle times after midday correctly. So we wrote another test - for the input `23:00`. We saw our implementation failed that test. And we fixed it. And we had an implementation that passed all our (2) tests! | ||
|
||
> When will we be happy that our implementation works for all possible inputs? When do we have enough tests? | ||
### Groups of input | ||
|
||
One way to approach this is to think about what _groups_ of input our problem may have. | ||
|
||
We've already identified two examples of groups of input to the problem of converting 24 hour clocks to 12 hour clocks: Times before midday and times after midday. | ||
|
||
One way to find extra cases to consider (and extra tests to write) is to try to think of different groups of input. | ||
|
||
For example, some times are exactly on the hour (end in `:00`) and other times have a non-zero number of minutes. | ||
|
||
{{<note type="exercise">}} | ||
Set a timer for 5 minutes. Write down as many groups of input to this problem as you can. Write an example assertion for each one. | ||
|
||
If you find any bugs in the implementation, go fix them! | ||
{{</note>}} | ||
|
||
### Edge cases | ||
|
||
Another way to consider this question is to think about what _edge cases_ there are in the problem. | ||
|
||
{{<note type="definition" title="Definition: edge case">}} | ||
An edge case is an unusual value which may need special treatment. | ||
|
||
Some examples are: the minimum value, the maximum value, and the boundary between two groups of input. | ||
{{</note>}} | ||
|
||
Some example edge cases for this problem are: | ||
`00:00` | ||
: The minimum time, which is `12:00 am` in 12 hour clock. | ||
This is also the only hour that is _bigger_ in 12 hour clock than 24 hour clock. | ||
|
||
`24:00` | ||
: The maximum time. | ||
|
||
`12:00` | ||
: Where time changes from am to pm. The edge between morning times and afternoon times. | ||
|
||
Often these edge cases are where bugs happen. | ||
|
||
{{<note type="exercise">}} | ||
Set a timer for 5 minutes. Write down as many edge cases of input to this problem as you can. Write an example assertion for each one. | ||
|
||
If you find any bugs in the implementation, go fix them! | ||
{{</note>}} |
101 changes: 101 additions & 0 deletions
101
common-content/en/module/js1/interpreting-errors/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
+++ | ||
title = '🔎 Interpreting errors' | ||
|
||
time = 20 | ||
facilitation = false | ||
emoji= '🔎' | ||
[objectives] | ||
1='Interpret an error trace to identify which line in which file caused the error' | ||
2="Identify an error message from an error trace" | ||
[build] | ||
render = 'never' | ||
list = 'local' | ||
publishResources = false | ||
|
||
+++ | ||
|
||
## An error is thrown | ||
|
||
When we run the file with Node, we get an error in the console: | ||
|
||
```console | ||
% node clock-example.js | ||
/Users/dwh/CYF/clock-example.js:12 | ||
const currentOutput = formatAs12HourClock("23:00"); | ||
^ | ||
|
||
SyntaxError: Identifier 'currentOutput' has already been declared | ||
at wrapSafe (node:internal/modules/cjs/loader:1383:18) | ||
at Module._compile (node:internal/modules/cjs/loader:1412:20) | ||
at Module._extensions..js (node:internal/modules/cjs/loader:1551:10) | ||
at Module.load (node:internal/modules/cjs/loader:1282:32) | ||
at Module._load (node:internal/modules/cjs/loader:1098:12) | ||
at TracingChannel.traceSync (node:diagnostics_channel:315:14) | ||
at wrapModuleLoad (node:internal/modules/cjs/loader:215:24) | ||
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5) | ||
at node:internal/main/run_main_module:30:49 | ||
|
||
Node.js v22.4.1 | ||
``` | ||
|
||
When an error is thrown, the program stops and an error report is sent to the user. | ||
|
||
As programmers, we will see a lot of errors. It's useful for us to be able to read them. | ||
|
||
### Interpreting the output | ||
|
||
Each line of output here tells us something useful. | ||
|
||
The first line is: | ||
|
||
``` | ||
/Users/dwh/CYF/clock-example.js:12 | ||
``` | ||
|
||
Your output was probably different. But it will have the same parts. Some text, then a colon (`:`), then a number. | ||
|
||
{{<note type="exercise" title="Exercise">}} | ||
|
||
Work out what the parts of this line mean. | ||
|
||
Why are they different on my computer than yours? | ||
|
||
How can we use both pieces of information? | ||
|
||
{{</note>}} | ||
|
||
Often, looking at one line of a file is enough to understand what's wrong. So the message also shows us a copy of the line that caused the problem: | ||
|
||
``` | ||
const currentOutput = formatAs12HourClock("23:00"); | ||
``` | ||
|
||
Then the output tells us the error message: | ||
|
||
``` | ||
SyntaxError: Identifier 'currentOutput' has already been declared | ||
``` | ||
|
||
We may not know what this means yet, but it's something we can learn about. | ||
|
||
{{<note type="exercise" title="Exercise">}} | ||
Write down three ways you could find out what this means. | ||
{{</note>}} | ||
|
||
Each line starting with "at" is showing us a "Stack trace". We'll skip over this for now. In the future we'll see how it can be useful to us. | ||
|
||
Finally, we have this line: | ||
|
||
``` | ||
Node.js v22.4.1 | ||
``` | ||
|
||
{{<note type="exercise" title="Exercise">}} | ||
|
||
What does this line mean? | ||
|
||
Why might it be useful to know this information? | ||
|
||
Add your answer to your spaced repetition calendar. Your understanding of this will grow over time. Answer the question again in the future, and compare it to your previous answer. | ||
|
||
{{</note>}} |
Oops, something went wrong.