Activity: Input Space Grammar
(no submission)
Purpose:
Applying syntax-based testing to input space to create test cases;
get ready to work on homework assignment,
and prepare for quiz 5 and the final exam
You may make a copy of a
worksheet
and complete this activity or type your answers in any text editor.
You may work alone or with at most two other students in this course.
Consider a simple stack class that has five operations:
Init: Create a new stack
Push: Add an item to the stack; the item is placed at the top of the stack
Pop: Pop an element from the top of the stack, remove that item from the stack
Peek: Obtain the item present at the top of the stack, does not remove it from the stack
Dispose: Destroy an existing stack
The following BNF grammar constrains how the stack is used.
A legal use is a sequence of stack operations that
is in the language defined by the grammar.
For example, the sequence "Init Push Pop Dispose" is legal.
An illegal use is a sequence of stack operations that is not
in the language defined by the grammar.
For example, the sequence "Init Peek" is illegal.
DoIt ::= X | X DoIt
X ::= "Init" "Dispose" | "Init" Y "Dispose"
Y ::= "Push" | "Push" Y | "Push" Z | "Push" Y Z
Z ::= "Peek" | "Pop" | "Peek" "Pop"
- Is it legal to Peek a non-empty stack?
Justify your answer by showing a derivation in the grammar.
- Give a valid input (strings) that satisfy Terminal Symbol Coverage (TSC)
- Give a minimal set of test requirements that satisfy
Production Coverage (PDC)
Consider the following regular expression for bank example and answer the questions
("deposit" account amount | "debit" account amount)*
- Draw a Finite State Machine (FSM) to represent the grammar
- Create 3 possible input strings from the grammar
Consider the following Backus-Naur Form (BNF) grammar for bank example and answer the questions
bank ::= action*
action ::= dep | deb
dep ::= "deposit" account amount
deb ::= "debit" account amount
account ::= digit4
amount ::= "$" digit+ "." digit2
digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
- Draw a Finite State Machine (FSM) to represent the grammar
- Create 3 possible ground (input) strings from the grammar
- Apply input grammar mutation operators to create mutants
- Nonterminal replacement operator replaces
every nonterminal symbol in a production
dep ::= "deposit" account amount
by other nonterminal symbols
- Terminal replacement operator replaces
every terminal symbol in a production
amount ::= "$" digit+ "." digit2
by other terminal symbols
- Terminal and nonterminal deletion operator deletes
every terminal and nonterminal symbol in a production
dep ::= "deposit" account amount
- Terminal and nonterminal duplication operator duplicates
every terminal and nonterminal symbol in a production
dep ::= "deposit" account amount