# Negative Testing and Mindfuck (Part 3)
goal: validation checks for source input and query input
A: ==> ditch this bitch
invalid source , dummy query <blank>
# B:
valid source, invalid query ==> semantics
### test_source_5.txt
```javascript
procedure procedure {
if = 0;
read while;
if (while != 0) then {
chara = 0;
procedure = 0;
while (while > 1) {
read procedure;
if (procedure != 99) then {
chara = chara + procedure;
lastByte = procedure;
if (procedure == 88) then {
if = if + 1;
print ProcessStmtNow;
chara = 0;
} else {
print cont1nueREad1ng;
}
while = while - 1;
} else {
print print;
}
}
} else {
print InvalidFileName;
}
if (while == 1) then {
print pr0cessSuccessfuI;
} else {
print print;
}
print if;
if = 0;
}
```
### test_queries_5.txt
```
1 - Gets all constant value
constant c;
Select c
0, 99, 88, 1
5000
2 - Gets all variables
variable v;
Select v
if, while, chara, procedure, lastByte, ProcessStmtNow, cont1nueREad1ng, print, 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)
procedure
5000
12 - Find all statement that modifies fileName
stmt s1;
Select s1 such that Modifies(s1, "while")
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, procedure, lastByte, if, while
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, print, InvalidFileName, if, 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 print
stmt Uses;
Select Uses such that Uses(Uses, "print")
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 procedure variable
assign a;
Select a pattern a(_, _"procedure"_)
9, 10
5000
20 - Find the stmt which assignment: lastByte = procedure;
assign a;
Select a pattern a("lastByte", _"procedure"_)
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, _)
if
5000
22 - Find all parent statement number which assigns to if
assign a; stmt ss;
Select ss such that Parent*(ss, a) pattern a("if", _)
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, "while") pattern a123("while", _"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 = procedure with BOOLEAN such that
assign procedure; if else;
Select procedure such that Modifies(else, "lastByte") pattern procedure("lastByte", _"procedure"_)
10
5000
29 - Find the if assignment that is not the first stmt
assign assign;
Select assign such that Follow(_, assign) pattern assign("if", _)
25
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
31 - Repeated declaration of the same assign statement (called assign) NEGATIVE TC
assign assign, assign;
Select assign
none
5000
32 - Repeated declaration of the same assign statement (not called assign) NEGATIVE TC
assign a, a;
Select a
none
5000
33 - Repeated declaration of the same if statement (called if) NEGATIVE TC
if if, if;
Select if
none
5000
34 - Repeated declaration of the same if statement (not called if) NEGATIVE TC
if ifs, ifs;
Select ifs
none
5000
35 - Repeated declaration of the same read statement (called read) NEGATIVE TC
read read, read;
Select read
none
5000
36 - Repeated declaration of the same read statement (not called read) NEGATIVE TC
read r, r;
Select r
none
5000
37 - Repeated declaration of the same print statement (called print)NEGATIVE TC
print print, print;
Select print
none
5000
38 - Repeated declaration of the same print statement (not called print) NEGATIVE TC
print p, p;
Select p
none
5000
39 - Repeated declaration of the same while statement (called while) NEGATIVE TC
while while, while;
Select while
none
5000
40 - Repeated declaration of the same while statement (not called while) NEGATIVE TC
while w, w;
Select w
none
5000
41 - Repeated declaration of the same statement (called stmt)NEGATIVE TC
stmt stmt, stmt;
Select stmt
none
5000
42 - Repeated declaration of the same statement (not called stmt) NEGATIVE TC
stmt s, s;
Select s
none
5000
43 - Repeated declaration of the same variable (called variable) NEGATIVE TC
variable variable, variable;
Select variable
none
5000
44 - Repeated declaration of the same variable (not called stmt) NEGATIVE TC
variable v, v;
Select v
none
5000
45 - Same synonym assigned to multiple types (assign and variable) NEGATIVE TC
assign a; variable a;
Select a;
none
5000
46 - Same synonym assigned to multiple types (while and variable) NEGATIVE TC
assign a; variable a;
Select a;
none
5000
47 - Allow for multiple synonyms to refer to the same statement POSITIVE assign a; assign b;
Select a such that Modifies(a, "char") pattern b("char", _"char"_)
9
5000
```
### Testing targets:
#### SOURCE
* similar to test_source_4 but with variable and procedure names that are keywords
# TEST 6
### test_source_6.txt
```javascript=
procedure if {
else = 10000000000000000000000000000000000;
procedure = (0);
}
```
### test_queries_6.txt
```javascript=
1 - Invalid synonym name
assign 1a;
Select 1a
none
5000
2 - Invalid synonym name
stmt 0a;
Select 0a
none
5000
3 - Invalid synonym name
stmt -a;
Select -a
none
5000
4 - Invalid synonym declaration
statement as;
Select as
none
5000
5 - Invalid synonym declaration
proc pen;
Select pen
none
5000
6 - Invalid synonym declaration
Variable var;
Select var
none
5000
7 - Invalid select
assign a ;
select a
none
5000
8 - Invalid select
stmt s ;
Select s;
none
5000
9 - No declaration
stmt s,ass ;
Select sass
none
5000
10 - Ambiguous modifies
stmt s ;
Select s such that Modifies(_, "else")
none
5000
11 - Ambiguous uses
stmt s ;
Select s such that uses(_, "0")
none
5000
12 - Pattern checking
assign ah;
Select ah pattern ah (_, _"(0)"_)
none
5000
13 - Pattern checking
assign ah;
Select ah pattern ah (_, _" 0 "_)
none
5000
14 - Invalid grammar (Pattern)
assign a1;
Select a1 pattern a1 (a1, _"0"_)
none
5000
15 - Invalid grammar (pattern)
variable v1;
Select v1 pattern v1 (v1, _"0"_)
none
5000
16 - Invalid grammar (such that)
variable v1;
Select v1 such that Uses(v1, v1)
none
5000
17 - Invalid grammar (such that)
variable v1, v2;
Select v1 such that Follows(v1, v2)
none
5000
18 - Invalid grammar (such that)
variable v1, v2; while w1;
Select v1 such that Parent*(w1, v2)
none
5000
19 - Multiple declarations
assign a; if a;
Select a
none
5000
```
### Testing targets:
#### SOURCE
* handle integer overflow gracefully
#### QUERIES
* negative testing for invalid syntax