Skip to content

Commit 2a70803

Browse files
committed
Updatig test file
1 parent 0a6114b commit 2a70803

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

exercises/practice/forth/forth.spec.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ describe('Forth', () => {
3737
forth.evaluate('1 +');
3838
}).toThrow(new Error('Stack empty'));
3939
});
40+
41+
xtest('more than two values on the stack', () => {
42+
forth.evaluate('1 2 3 +');
43+
expect(forth.stack).toEqual([1, 5]);
44+
});
4045
});
4146

4247
describe('subtraction', () => {
@@ -56,6 +61,11 @@ describe('Forth', () => {
5661
forth.evaluate('1 -');
5762
}).toThrow(new Error('Stack empty'));
5863
});
64+
65+
xtest('more than two values on the stack', () => {
66+
forth.evaluate('1 12 3 -');
67+
expect(forth.stack).toEqual([1, 9]);
68+
});
5969
});
6070

6171
describe('multiplication', () => {
@@ -75,6 +85,11 @@ describe('Forth', () => {
7585
forth.evaluate('1 *');
7686
}).toThrow(new Error('Stack empty'));
7787
});
88+
89+
xtest('more than two values on the stack', () => {
90+
forth.evaluate('1 2 3 *');
91+
expect(forth.stack).toEqual([1, 6]);
92+
});
7893
});
7994

8095
describe('division', () => {
@@ -105,6 +120,11 @@ describe('Forth', () => {
105120
forth.evaluate('1 /');
106121
}).toThrow(new Error('Stack empty'));
107122
});
123+
124+
xtest('more than two values on the stack', () => {
125+
forth.evaluate('1 12 3 /');
126+
expect(forth.stack).toEqual([1, 4]);
127+
});
108128
});
109129

110130
describe('combined arithmetic', () => {
@@ -117,6 +137,16 @@ describe('Forth', () => {
117137
forth.evaluate('2 4 * 3 /');
118138
expect(forth.stack).toEqual([2]);
119139
});
140+
141+
xtest('multiplication and addition', () => {
142+
forth.evaluate('1 3 4 * +');
143+
expect(forth.stack).toEqual([13]);
144+
});
145+
146+
xtest('addition and multiplication', () => {
147+
forth.evaluate('1 3 4 + *');
148+
expect(forth.stack).toEqual([7]);
149+
});
120150
});
121151

122152
describe('dup', () => {
@@ -250,11 +280,12 @@ describe('Forth', () => {
250280
expect(forth.stack).toEqual([11]);
251281
});
252282

253-
xtest('cannot redefine numbers', () => {
283+
xtest('cannot redefine non-negative numbers', () => {
254284
expect(() => {
255285
forth.evaluate(': 1 2 ;');
256286
}).toThrow(new Error('Invalid definition'));
257287
});
288+
258289
xtest('cannot redefine negative numbers', () => {
259290
expect(() => {
260291
forth.evaluate(': -1 2 ;');

0 commit comments

Comments
 (0)