Skip to content

Commit beeed47

Browse files
committed
Make the tests run again
1 parent 1270b76 commit beeed47

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

04_data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ computation. Comments are not allowed in JSON.
12551255

12561256
A journal entry might look like this when represented as JSON data:
12571257

1258-
```{type: "application/json"}
1258+
```{lang: "application/json"}
12591259
{
12601260
"squirrel": false,
12611261
"events": ["work", "touched tree", "pizza", "running"]

10_modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ useful (and useless) packages from it.
671671
These are the bindings that the project from [Chapter ?](robot)
672672
creates:
673673

674-
```{type: "text/plain"}
674+
```{lang: "text/plain"}
675675
roads
676676
buildGraph
677677
roadGraph

13_browser.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ such as web pages or pictures). It specifies the way the side making
6464
the request should start with a line like this, naming the resource
6565
and the version of the protocol that it is trying to use.
6666

67-
```{type: "text/plain"}
67+
```{lang: "text/plain"}
6868
GET /index.html HTTP/1.1
6969
```
7070

@@ -349,7 +349,7 @@ rest of the page will be interpreted as part of the script.
349349

350350
{{index "relative path", dependency}}
351351

352-
You can load ((ES modules)) (see [Chapter ?](module#es)) in the
352+
You can load ((ES modules)) (see [Chapter ?](modules#es)) in the
353353
browser by giving your script tag a `type="module"` attribute. Such
354354
modules can depend on other modules by using ((URL))s relative to
355355
themselves as module names in `import` declarations.

20_node.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ The robot simulation from [Chapter ?](#robot), as modularized in
285285
[Exercise 10.1](modules#modular_robot), might use a `package.json`
286286
file like this:
287287

288-
```
288+
```{lang: "application/json"}
289289
{
290290
"author": "Marijn Haverbeke",
291291
"name": "eloquent-javascript-robot",
@@ -669,7 +669,7 @@ The following piece of code, when run with the uppercasing server
669669
active, will send a request to that server and write out the response
670670
it gets:
671671

672-
```{test: no}
672+
```
673673
const {request} = require("http");
674674
request({
675675
hostname: "localhost",

21_skillsharing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ talks to the client, so we first define a helper method that builds up
553553
such an array and includes an `ETag` header in the response.
554554

555555
```{includeCode: ">code/skillsharing/skillsharing_server.js"}
556-
SkillShareServer.prototype.talkResponse = function(talks) {
556+
SkillShareServer.prototype.talkResponse = function() {
557557
let talks = [];
558558
for (let title of Object.keys(this.talks)) {
559559
talks.push(this.talks[title]);
@@ -612,7 +612,7 @@ SkillShareServer.prototype.waitForChanges = function(time) {
612612
resolve({status: 304});
613613
}, time * 1000);
614614
});
615-
}
615+
};
616616
```
617617

618618
{{index "updated method"}}

src/run_tests.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ let varify = require("./varify")
99

1010
let file = process.argv[2]
1111
let chapNum = Number(file.match(/^\d*/)[0])
12+
let doRun = ![10, 11, 20, 21].includes(chapNum)
1213
let input = fs.readFileSync(file, "utf8")
1314

1415
let baseCode = "let alert = function() {}, prompt = function() { return 'x' }, confirm = function() { return true }; window = this; requestAnimationFrame = setTimeout = clearTimeout = setInterval = clearInterval = Math.min; let localStorage = {setItem: function(a, b) { this[a] = b;}, getItem: function(a) { return this[a] || null }, removeItem: function(a) { delete this[a] }};\n"
@@ -89,11 +90,11 @@ while (m = re.exec(input)) {
8990
function stripHTML(code) {
9091
let included = "", script = ""
9192
code = code.replace(/<script\b[^>]*?(?:\bsrc\s*=\s*('[^']+'|"[^"]+"|[^\s>]+)[^>]*)?>([\s\S]*?)<\/script>/, function(m, src, content) {
92-
if (src) {
93+
if (!src) {
94+
script += content
95+
} else if (doRun) {
9396
if (/["']/.test(src.charAt(0))) src = src.slice(1, src.length - 1)
9497
included += fs.readFileSync("html/" + src, "utf8")
95-
} else {
96-
script += content
9798
}
9899
return ""
99100
})
@@ -242,7 +243,7 @@ function nextSandbox() {
242243
if (i == boxes.length) return
243244
let sandbox = boxes[i]
244245
i++
245-
if (chapNum < 12 || chapNum >= 20) { // Language-only
246+
if (chapNum < 13 || chapNum >= 20) { // Language-only
246247
try {
247248
;(new Function("console, require, module", baseCode + sandbox.code))(_console, chapNum >= 20 && fakeRequire, {})
248249
nextSandbox()
@@ -269,4 +270,4 @@ function nextSandbox() {
269270
})
270271
}
271272
}
272-
if (chapNum != 11) nextSandbox()
273+
if (doRun) nextSandbox()

0 commit comments

Comments
 (0)