Submitted by: Submitted by aldumil
Views: 10
Words: 1194
Pages: 5
Category: US History
Date Submitted: 05/08/2016 05:19 PM
Project 2
CMSC 330
May 8, 2016
Joshua Farquhar
Project 2 Documentation
Test Plan:
For the test plan we want a positive and negative result. To that end we will have three tests. The first will consist of a correct input file that should work. The second will use an input file known to contain errors in the syntax. The third will use an input file known to contain mathematical errors (divide by zero…etc).
Test Plan 1: Good input.
Test one uses an input file that contains the following:
(x+(2|4)), x=5; /* 6 */
(1:2?(x>0)), x=5; /* 1 */
(x + (y * 3)), x = 5, y = 2; /* 11 */
(x | y), x = 0, y = 0; /* 0 */
(x | y), x = -2, y = 0; /* 1 */
(x | (y | z)), x = 0, y = 0, z = 1; /* 1 */
(x & y), x = 0, y = 0; /* 0 */
(x & y), x = -2, y = -1; /* 1 */
(x & (y & z)), x = 0, y = 0, z = 0; /* 0 */
(x & (y & z)), x = 1, y = 1, z = 1; /* 1 */
(x = y), x = 0, y = 0; /* 1 */
(x = y), x = 1, y = 0; /* 0 */
(x : y ? z), x = 1, y = 0, z = 0; /* 0 */
(x : y ? z), x = 1, y= 2,z = 1; /* 1 */
(x !), x = 0; /* 1 */
(x !), x = 1; /* 0 */
(x>1), x=5; /* 1 */
(x<5), x=1; /* 1 */
(x=3), x=6; /* 0 */
(x&3), x=8; /* 1 */
(x > y), x = 0, y = 5; /* 0 */
(x > y), x = 9, y = 0; /* 1 */
(x < y), x = 6, y = 2; /* 0 */
(x < y), x = -2, y = 4; /* 1 */
This test attempted to use as many combinations of the mathematical operators as we could without being excessive. On each line enclosed by “/* */” is what that line should be evaluated to by the program. The results from command line are:
As expected this input file is parsed correctly and the program outputs the exact values that we want.
Test Plan 2: Bad syntax
For this test we use the same input file but alter the first few lines:
"(x+(2|4)), x=5; /* 6 */
:(1:2?(x>0)), x=5; /* 1 */
()((x + (y * 3)), x = 5, y = 2; /* 11 */
(x | y), x = 0, y = 0; /* 0 */
(x | y), x = -2, y = 0; /* 1 */
(x | (y | z)), x = 0, y = 0, z = 1; /* 1 */
(x & y), x = 0, y...