| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,34 +5,25 @@ | |||
| 5 | 5 | */ | |
| 6 | 6 | ||
| 7 | 7 | const common = require('../common'); | |
| 8 | - var assert = require('assert'); | ||
| 9 | - var http = require('http'); | ||
| 10 | - | ||
| 11 | - var hadError = 0; | ||
| 8 | + const assert = require('assert'); | ||
| 9 | + const http = require('http'); | ||
| 12 | 10 | ||
| 13 | 11 | function httpreq(count) { | |
| 14 | - if (1 < count) return; | ||
| 12 | + if (count > 1) return; | ||
| 15 | 13 | ||
| 16 | - var req = http.request({ | ||
| 14 | + const req = http.request({ | ||
| 17 | 15 | host: 'not-a-real-domain-name.nobody-would-register-this-as-a-tld', | |
| 18 | 16 | port: 80, | |
| 19 | 17 | path: '/', | |
| 20 | 18 | method: 'GET' | |
| 21 | 19 | }, common.fail); | |
| 22 | 20 | ||
| 23 | - req.on('error', function(e) { | ||
| 24 | - console.log(e.message); | ||
| 21 | + req.on('error', common.mustCall((e) => { | ||
| 25 | 22 | assert.strictEqual(e.code, 'ENOTFOUND'); | |
| 26 | - hadError++; | ||
| 27 | 23 | httpreq(count + 1); | |
| 28 | - }); | ||
| 24 | + })); | ||
| 29 | 25 | ||
| 30 | 26 | req.end(); | |
| 31 | 27 | } | |
| 32 | 28 | ||
| 33 | 29 | httpreq(0); | |
| 34 | - | ||
| 35 | - | ||
| 36 | - process.on('exit', function() { | ||
| 37 | - assert.equal(2, hadError); | ||
| 38 | - }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments