# System Testing Part 2
______
## Source-Query Pair 4
### test_source_4.txt
```javascript
procedure Parser {
psubsystem = 0;
read fileName;
if (fileName != 0) then {
chara = 0;
byte = 0;
while (fileName > 1) {
read byte;
if (byte != 99) then {
chara = chara + byte;
lastByte = byte;
if (byte == 88) then {
psubsystem = psubsystem + 1;
print ProcessStmtNow;
chara = 0;
} else {
print cont1nueREad1ng;
}
fileName = fileName - 1;
} else {
print SyntaxErr0rFound;
}
}
} else {
print InvalidFileName;
}
if (fileName == 1) then {
print pr0cessSuccessfuI;
} else {
print SyntaxErr0rFound;
}
print psubsystem;
psubsystem = 0;
}
```
```javascript=
procedure Parser {
psubsystem = 0; //1
read fileName; //2
if (fileName != 0) then { //3
chara = 0; //4
byte = 0; //5
while (fileName > 1) { //6
read byte; //7
if (byte != 99) then { //8
chara = chara + byte; //9
lastByte = byte; //10
if (byte == 88) then { //11
psubsystem = psubsystem + 1; //12
print ProcessStmtNow; //13
chara = 0; //14
} else {
print cont1nueREad1ng; //15
}
fileName = fileName - 1; //16
} else {
print SyntaxErr0rFound; //17
}
}
} else {
print InvalidFileName; //18
}
if (fileName == 1) then { //19
print pr0cessSuccessfuI; //20
} else {
print SyntaxErr0rFound; //21
}
print psubsystem; //22
psubsystem = 0; //23
}
```
### Testing Targets:
#### SOURCE
* Deep level nesting of if loop (with a while loop within).
* Print and Read uses different variable name
* Ends StmtLst with Else Container or Assignment Stmt
* Uses Conditional Operator: !=, ==, >
* Varied variable names based.
### test_queries_6.txt
```javascript=
1 - Gets all constant value
constant c;
Select c
0, 99, 88, 1
5000
2 - Gets all variables
variable v;
Select v
psubsystem, fileName, chara, byte, lastByte, ProcessStmtNow, cont1nueREad1ng, SyntaxErr0rFound, InvalidFileName, pr0cessSuccessfuI
5000
3 - Get all if statement
if ifs;
Select ifs
3, 8, 11, 19
5000
4 - Get all assign statement
assign a1;
Select a1
1, 4, 5, 9, 10, 12, 14, 16, 23
5000
5 - Get all read statement
read r1;
Select r1
2, 7
5000
6 - Get the stmtList of if-statement 8
stmt s;
Select s such that Parent*(8, s)
9, 10, 11, 12, 13, 14, 15, 16, 17
5000
7 - Get the stmtList of while-statement
while w; stmt s;
Select s such that Parent(w, s)
7, 8
5000
8 - Get the stmt with boolean Parent
stmt s123;
Select s123 such that Parent(1, 2)
none
5000
9 - Find all children in procedure
stmt s; if if;
Select s such that Follows*(if, _)
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
5000
10 - Find all print stmt following an if-statement
print p; if ifs;
Select p such that Follows(ifs, p)
22
5000
11 - Find all procedure with BOOLEAN Follows
procedure p1;
Select p1 such that Follows*(2, 23)
Parser
5000
12 - Find all statement that modifies fileName
stmt s1;
Select s1 such that Modifies(s1, "fileName")
2, 3, 6, 8, 16
5000
13 - Find all variable modified in if-statement
variable vv; if ifffff;
Select vv such that Modifies(ifffff, vv)
chara, byte, lastByte, psubsystem, fileName
5000
14 - Find stmt with BOOLEAN Modified by while
while www; stmt s;
Select s such that Modifies(www, _)
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
5000
15 - Gets all print variable name
print p; variable v;
Select v such that Uses(p, v)
ProcessStmtNow, cont1nueREad1ng, SyntaxErr0rFound, InvalidFileName, psubsystem, pr0cessSuccessfuI
5000
16 - Find all read statement with BOOLEAN (false)
read rr;
Select rr such that Uses(_, "lastByte")
none
5000
17 - Find all stmt that prints a SyntaxErr0rFound
stmt Uses;
Select Uses such that Uses(Uses, "SyntaxErr0rFound")
3, 6, 8, 17, 19, 21
5000
18 - Find all stmt state reset / initializer
assign pattern;
Select pattern pattern pattern(_, _"0"_)
1, 4, 5, 14, 23
5000
19 - Find the stmt which uses byte variable
assign a;
Select a pattern a(_, _"byte"_)
9, 10
5000
20 - Find the stmt which assignment: lastByte = byte;
assign a;
Select a pattern a("lastByte", _"byte"_)
10
5000
21 - Gets all print variable name that are declared before
print p; variable v; assign a;
Select v such that Uses(p, v) pattern a(v, _)
psubsystem
5000
22 - Find all parent statement number which assigns to psubsystem
assign a; stmt ss;
Select ss such that Parent*(ss, a) pattern a("psubsystem", _)
3, 6, 8, 11
5000
23 - Find the statements that modifies fileName with fileName = 1;
stmt s; assign a123;
Select s such that Modifies(s, "fileName") pattern a123("fileName", _"1"_)
2, 3, 6, 8, 16
5000
24 - Gets all counter-type stmt
assign a; variable v;
Select a such that Uses(a, v) pattern a(v, _"1"_)
12, 16
5000
25 - Find all stmt state reset / initializer which are nested in a container
assign a;
Select a such that Parent*(_,a) pattern a(_, _"0"_)
4, 5, 14
5000
26 - Find a back-to-back if statement with BOOLEAN pattern
if ifs, ifss; assign a;
Select ifss such that Follows(ifs, ifss) pattern a(_, _)
19
5000
27 - Find a assignment stmt with chara variable, not first in stmtLst
assign a1,a2,a3,a4,a5;
Select a4 such that Follows(_, a4) pattern a4("chara", _)
14
5000
28 - Find the stmt which assignment: lastByte = byte with BOOLEAN such that
assign procedure; if else;
Select procedure such that Modifies(else, "lastByte") pattern procedure("lastByte", _"byte"_)
10
5000
29 - Find the psubsystem assignment that is not the first stmt
assign assign;
Select assign such that Follow(_, assign) pattern assign("psubsystem", _)
23
5000
30 - Find the stmt that prints pr0cessSuccessfuI with BOOLEAN pattern
assign qwerty1; print printer;
Select printer such that Uses(printer, "pr0cessSuccessfuI") pattern qwerty1(_, _"1"_)
20
5000