Skip to content

[LAB5] 313561001 #361

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

Open
wants to merge 8 commits into
base: 313561001
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions lab3/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,57 @@ const assert = require('assert');
const { Calculator } = require('./main');

// TODO: write your tests here
it('Param-Error', () => {
const exp_testcases = [
{param: NaN, expected: {name: 'Error', message: 'unsupported operand type'}},
{param: 9999999, expected: {name: 'Error', message: 'overflow'}}
];

const Calc = new Calculator();

for( const ts of exp_testcases){
assert.throws(() => {
Calc.exp(ts.param);
}, ts.expected
);
};

const log_testcases = [
{param: NaN, expected: {name: 'Error', message: 'unsupported operand type'}},
{param: 0, expected: {name: 'Error', message: 'math domain error (1)'}},
{param: -1, expected: {name: 'Error', message: 'math domain error (2)'}}
];

for( const ts of log_testcases){
assert.throws(() => {
Calc.log(ts.param);
}, ts.expected
);
};

})

it('test', () => {
const exp_testcases = [
{param: 0, expected: 1},
{param: 1, expected: Math.exp(1)},
{param: -1, expected: Math.exp(-1)}
];

const Calc = new Calculator();

for( const ts of exp_testcases){
assert.strictEqual(Calc.exp(ts.param), ts.expected);
};

const log_testcases = [
{param: 9, expected: Math.log(9)},
{param: 1, expected: Math.log(1)},
{param: 100, expected: Math.log(100)}
];

for( const ts of log_testcases){
assert.strictEqual(Calc.log(ts.param), ts.expected);
};

})
4 changes: 4 additions & 0 deletions lab5/antiasan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

void antiasan(unsigned long addr)
{
unsigned long shadow_addr = ((addr + 0x87 ) >> 3) + 0x7fff8000;

for (int i = 0; i < 4; i += 1) {
*(unsigned int *)(shadow_addr + i * 4) = 0;
}
}
Loading