From b791fb6d1e10155ea6aab0d96aef9600a48261eb Mon Sep 17 00:00:00 2001 From: zhilv Date: Tue, 2 Dec 2025 11:41:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(server.tests.test7):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=20server=20=E5=AE=9E=E9=AA=8C=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/README.md | 3 ++- Server/tests/test7/.gitignore | 2 ++ Server/tests/test7/index.js | 12 ++++++++++++ Server/tests/test7/index2.js | 23 +++++++++++++++++++++++ Server/tests/test7/index3.js | 27 +++++++++++++++++++++++++++ Server/tests/test7/index4.js | 21 +++++++++++++++++++++ Server/tests/test7/package.json | 13 +++++++++++++ 7 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 Server/tests/test7/.gitignore create mode 100644 Server/tests/test7/index.js create mode 100644 Server/tests/test7/index2.js create mode 100644 Server/tests/test7/index3.js create mode 100644 Server/tests/test7/index4.js create mode 100644 Server/tests/test7/package.json diff --git a/Server/README.md b/Server/README.md index e19486b..e2620e5 100644 --- a/Server/README.md +++ b/Server/README.md @@ -19,5 +19,6 @@ ├── test3 # 实验3 ├── test4 # 实验4 ├── test5 # 实验5 - └── test6 # 实验6 + ├── test6 # 实验6 + └── test7 # 实验7 ``` diff --git a/Server/tests/test7/.gitignore b/Server/tests/test7/.gitignore new file mode 100644 index 0000000..f52e6f5 --- /dev/null +++ b/Server/tests/test7/.gitignore @@ -0,0 +1,2 @@ +node_modules +pnpm-lock.yaml \ No newline at end of file diff --git a/Server/tests/test7/index.js b/Server/tests/test7/index.js new file mode 100644 index 0000000..d9c4aa0 --- /dev/null +++ b/Server/tests/test7/index.js @@ -0,0 +1,12 @@ +console.log("开始"); + +setTimeout(() => { + console.log("Timeout"); +}, 0); + +setImmediate(() => { + console.log("Immediate"); +}); + +console.log("结束"); + diff --git a/Server/tests/test7/index2.js b/Server/tests/test7/index2.js new file mode 100644 index 0000000..b4c1852 --- /dev/null +++ b/Server/tests/test7/index2.js @@ -0,0 +1,23 @@ +console.log("Start"); + +setTimeout(() => { + console.log("Timeout1"); +}, 1000); + +let a = 1; +const intervalId = setInterval(() => { + console.log(a++); + clearInterval(this); + clearInterval(intervalId) +}, 1000); + +setTimeout(() => { + console.log("Timeout2"); +}, 1000); + +setImmediate(() => { + console.log("Immediate"); +}); + +console.log("End"); + diff --git a/Server/tests/test7/index3.js b/Server/tests/test7/index3.js new file mode 100644 index 0000000..daa5b4e --- /dev/null +++ b/Server/tests/test7/index3.js @@ -0,0 +1,27 @@ +const fs = require("fs"); +const path = require("path"); + +console.log("Start"); + +fs.readFile(path.join(__dirname, "/example.html"), 'utf8', (err, data) => { + console.log(data); + if (err) { + console.log(__dirname); + console.log(err.message); + } + + setTimeout(() => { + console.log("Timeout"); + }, 0); + + setImmediate(() => { + console.log("Immediate"); + }); + + process.nextTick(() => { + console.log("Next Tick"); + }); +}) + +console.log("End"); + diff --git a/Server/tests/test7/index4.js b/Server/tests/test7/index4.js new file mode 100644 index 0000000..a600f32 --- /dev/null +++ b/Server/tests/test7/index4.js @@ -0,0 +1,21 @@ +console.log("Start"); + +setTimeout(() => { + console.log("Timeout"); +}, 0); + +setImmediate(() => { + console.log("Immediate"); +}); + +process.nextTick(() => { + console.log("Next Tick 1"); +}); + +process.nextTick(() => { + console.log("Next Tick 2"); +}); + +console.log("End"); + + diff --git a/Server/tests/test7/package.json b/Server/tests/test7/package.json new file mode 100644 index 0000000..8da8de5 --- /dev/null +++ b/Server/tests/test7/package.json @@ -0,0 +1,13 @@ +{ + "name": "test7", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "packageManager": "pnpm@10.14.0" +}