In order to understand how to apply Model Checking, I am wondering how to apply it to a pseudo-realistic async program.
Say I have the following pseudocode:
var array = []
window.onclick = a
function a() {
setTimeout(b, 10)
}
function b() {
setTimeout(c, 100)
}
function c() {
var data = new Data(1)
array.push(data)
}
function Data(integer) {
this.integer = integer
}
The program asynchronously does a() -> b() -> c() on click and constructs a new Data object.
Say I have a specification that says "The program will eventually create a Data object on click within 200ms". Wondering what the Model Checker does to prove that this is correct in the program.
So first I rewrite my program as a state machine.
- State
start- Transition to State
idle.
- Transition to State
- State
idle- Transition
clickto Statea.
- Transition
- State
a- Transition
setTimeoutto Stateb.
- Transition
- State
b- Transition
setTimeoutto Statec.
- Transition
- State
c- Transition "function" to State
d(doesvar data = new Data(1); array.push(data)).
- Transition "function" to State
- State
d- Transition to State
idle
- Transition to State
Then the model checker starts at the start state and needs a "click" event to trigger going to state a. Wondering what the model checker path/trace will look like going from start to state d. That will help in understanding how to apply model checking. I don't see how to provide the click event to the model checker or how it should prove the Data statement. It seems like there needs to be some sort of testing/input generation going on but not quite sure (like for generating a fake click event for example).