File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -3,3 +3,21 @@ const assert = require('assert');
3
3
const { Calculator } = require ( './main' ) ;
4
4
5
5
// TODO: write your tests here
6
+ describe ( 'Calculator' , ( ) => {
7
+ it ( 'should calculate exp correctly' , ( ) => {
8
+ const calculator = new Calculator ( ) ;
9
+ const infiniteValue = Infinity ;
10
+ assert . throws ( ( ) => calculator . exp ( infiniteValue ) , Error ) ;
11
+ assert . throws ( ( ) => calculator . exp ( Number . MAX_VALUE ) , Error ) ;
12
+ assert . strictEqual ( calculator . exp ( 1 ) , Math . exp ( 1 ) ) ;
13
+ } ) ;
14
+
15
+ it ( 'should calculate log correctly' , ( ) => {
16
+ const calculator = new Calculator ( ) ;
17
+ const infiniteValue = Infinity ;
18
+ assert . throws ( ( ) => calculator . log ( infiniteValue ) , Error ) ;
19
+ assert . strictEqual ( calculator . log ( 2 ) , Math . log ( 2 ) ) ;
20
+ assert . throws ( ( ) => calculator . log ( 0 ) , Error ) ;
21
+ assert . throws ( ( ) => calculator . log ( - 1 ) , Error ) ;
22
+ } ) ;
23
+ } ) ;
You can’t perform that action at this time.
0 commit comments