Skip to content

[LAB6] 510558017 #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2233c14
fix: improve workflows
AlaRduTP Mar 13, 2024
e2b8057
fix: scripts/rebase-all.sh will fail due to too frequent remote opera…
AlaRduTP Mar 13, 2024
8336df3
feat: lab2
AlaRduTP Mar 13, 2024
0f5c5dd
feat: merge-all
AlaRduTP Mar 13, 2024
ff4a4f9
Merge branch 'SQLab:main' into main
as10748569 Mar 13, 2024
5fa8ffe
remove: create-branches.sh
AlaRduTP Mar 20, 2024
354fae7
feat: auto resolve conflicts when merging
AlaRduTP Mar 20, 2024
e49fa08
feat: improve GitHub workflows
AlaRduTP Mar 20, 2024
c895269
feat: lab3
AlaRduTP Mar 20, 2024
22a9521
feat: an easy check for changed files
AlaRduTP Mar 20, 2024
15ca1a7
doc: detailed steps of syncing fork
AlaRduTP Mar 20, 2024
dd650d8
fix: remove trailing whitespace
AlaRduTP Mar 20, 2024
0b0f42d
Merge branch 'SQLab:main' into main
as10748569 Mar 20, 2024
0879aa5
Update main_test.js
as10748569 Mar 27, 2024
70f40d0
Update main_test.js
as10748569 Mar 27, 2024
65dd00b
Delete lab3 directory
as10748569 Mar 27, 2024
a2661bf
Update main_test.js
as10748569 Mar 27, 2024
23a3b2a
Committing local changes
as10748569 Mar 27, 2024
bc15e10
Merge branch 'main' of github.com:as10748569/510558017 into main
as10748569 Mar 27, 2024
f29830f
Merge branch '510558017' of github.com:as10748569/510558017 into main
as10748569 Mar 27, 2024
cee6631
feat: add node_modules into gitignore
AlaRduTP Mar 27, 2024
ffbfbd7
feat: lab4
AlaRduTP Mar 27, 2024
4ea0c26
Merge branch 'SQLab:main' into main
as10748569 Apr 8, 2024
dac019e
Update main_test.js
as10748569 Apr 8, 2024
e58a89c
Update main_test.js
as10748569 Apr 8, 2024
1344a3d
Update main_test.js
as10748569 Apr 16, 2024
b7322a0
Update main_test.js
as10748569 Apr 16, 2024
5ee9d55
Add lab5
YingMuo Apr 17, 2024
86b3714
Fix github action
YingMuo Apr 17, 2024
c27f68f
Fix README.md
YingMuo Apr 17, 2024
419ed6d
fix: gh-script syntax error
AlaRduTP Apr 17, 2024
41cc403
add: lab6
YingMuo Apr 24, 2024
9777d36
feat: lab6
YingMuo Apr 24, 2024
110400a
fix: lab6
YingMuo Apr 24, 2024
eae2c35
fix: lab6
YingMuo Apr 24, 2024
2063787
Fix: lab6
YingMuo Apr 24, 2024
a2f55d5
Add: lab7
YingMuo May 1, 2024
56585b1
Fix: lab7
YingMuo May 1, 2024
7a945c9
Fix: lab7, angr not installed
YingMuo May 1, 2024
aadcbfb
Merge branch 'main' of github.com:as10748569/510558017 into main
as10748569 May 1, 2024
1f97d4e
Merge branch 'SQLab:main' into main
as10748569 May 8, 2024
8688699
Merge branch '510558017' into lab6
as10748569 May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
64 changes: 62 additions & 2 deletions lab2/main_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,66 @@
const test = require('node:test');
const assert = require('assert');
const fs = require('fs');
test.mock.method(fs, 'readFile', (file, options, callback) => {
callback(null, 'Guan\nChen\nGala');
});
const { Application, MailSystem } = require('./main');

// TODO: write your tests here
// Remember to use Stub, Mock, and Spy when necessary
test("Test MailSystem's write", () => {
const myClass = new MailSystem()
assert.strictEqual( myClass.write("Guan"),"Congrats, Guan!")
});

test("Test MailSystem's send(name, context)", () => {
Math.random = () => 0.6
const mailSystem = new MailSystem()
const context = mailSystem.write("Guan")
const success = mailSystem.send("Guan",context)
assert.strictEqual(success,true)
Math.random = () => 0.5
assert.strictEqual(mailSystem.send("Chen",context),false)
});

test("Test Application's getNames", async () => {
const application = new Application
const [people, selected] = await application.getNames()
assert.deepStrictEqual(people, ["Guan", "Chen", "Gala"])
assert.deepStrictEqual(selected, [])
});

test("Test Application's getRandomPerson()", (t) => {
const application = new Application
application.people = ["Guan", "Chen", "Gala"]
Math.random = () => 0
assert.deepStrictEqual(application.getRandomPerson(), "Guan");
Math.random = () => 0.6
assert.deepStrictEqual(application.getRandomPerson(), "Chen");
Math.random = () => 0.9
assert.deepStrictEqual(application.getRandomPerson(), "Gala");
});

test("Test Application's selectNextPerson", async() => {
const application = new Application
const name_list = await application.getNames();
application.selected = ["Guan"]
let count = 0;
test.mock.method(application, 'getRandomPerson', () => {
if (count <= name_list.length) {
return name_list[0][count++];
}
});
assert.strictEqual(application.selectNextPerson(), "Chen")
assert.strictEqual(application.selectNextPerson(), "Gala")
assert.strictEqual(application.selectNextPerson(), null)
});

test("Test Application's notifySelected() ", () => {
const application = new Application
application.people = ["Guan", "Chen", "Gala"]
application.selected = ["Guan", "Chen", "Gala"]
application.mailSystem.write = test.mock.fn(application.mailSystem.write)
application.mailSystem.send = test.mock.fn(application.mailSystem.send)
application.notifySelected()
assert.strictEqual(application.mailSystem.send.mock.calls.length, application.people.length);
assert.strictEqual(application.mailSystem.write.mock.calls.length, application.people.length);
});
139 changes: 139 additions & 0 deletions lab2/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions lab2/node_modules/@sinonjs/commons/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions lab2/node_modules/@sinonjs/commons/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions lab2/node_modules/@sinonjs/commons/lib/called-in-order.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading