-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit number of choices in choose expression to at most 10000 (#725)
* Limit number of choices in a choose(.) to atmost 10,000 Adds throwing a compile-time or runtime error if the number of choices in a choose(.) is greater than 10000. Updates GitHub docs to reflect this change. * Adds regression tests for choose exceeding 10000 choices * [PSym] Throw error if number of choices are greater than 10000
- Loading branch information
Showing
13 changed files
with
158 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Tst/RegressionTests/Feature3Exprs/DynamicError/tooManyChoicesInt/tooManyChoicesInt.p
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
machine Main { | ||
start state S { | ||
entry { | ||
var x: int; | ||
var y: int; | ||
|
||
x = 10000; | ||
y = choose(x); // OK | ||
print format("y is {0}", y); | ||
|
||
x = 10001; | ||
y = choose(x); // error | ||
print format("y is {0}", y); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Tst/RegressionTests/Feature3Exprs/DynamicError/tooManyChoicesMap/tooManyChoicesMap.p
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
machine Main { | ||
start state S { | ||
entry { | ||
var x: map[int, int]; | ||
var y: int; | ||
var i: int; | ||
|
||
i = 0; | ||
while (i < 10000) { | ||
x[i] = i; | ||
i = i + 1; | ||
} | ||
|
||
y = choose(x); // OK | ||
print format("y is {0}", y); | ||
|
||
x[i] = i; | ||
y = choose(x); // error | ||
print format("y is {0}", y); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Tst/RegressionTests/Feature3Exprs/DynamicError/tooManyChoicesSeq/tooManyChoicesSeq.p
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
machine Main { | ||
start state S { | ||
entry { | ||
var x: seq[int]; | ||
var y: int; | ||
var i: int; | ||
|
||
i = 0; | ||
while (i < 10000) { | ||
x += (i, i); | ||
i = i + 1; | ||
} | ||
|
||
y = choose(x); // OK | ||
print format("y is {0}", y); | ||
|
||
x += (i, i); | ||
y = choose(x); // error | ||
print format("y is {0}", y); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Tst/RegressionTests/Feature3Exprs/DynamicError/tooManyChoicesSet/tooManyChoicesSet.p
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
machine Main { | ||
start state S { | ||
entry { | ||
var x: set[int]; | ||
var y: int; | ||
var i: int; | ||
|
||
i = 0; | ||
while (i < 10000) { | ||
x += (i); | ||
i = i + 1; | ||
} | ||
y = choose(x); // OK | ||
print format("y is {0}", y); | ||
x += (i); | ||
y = choose(x); // error | ||
print format("y is {0}", y); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Tst/RegressionTests/Feature3Exprs/StaticError/tooManyChoices/tooManyChoices.p
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
machine Main { | ||
start state S { | ||
entry { | ||
var x: int; | ||
var y: int; | ||
|
||
x = choose(10000); // OK | ||
print format("x is {0}", x); | ||
|
||
y = choose(10001); // error | ||
print format("y is {0}", y); | ||
} | ||
} | ||
} |