File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,20 @@ public void ShouldThrowStatementCountOverflow()
13
13
) ;
14
14
}
15
15
16
+ [ Fact ]
17
+ public void ShouldCountStatementsPrecisely ( )
18
+ {
19
+ var script = "var x = 0; x++; x + 5" ;
20
+
21
+ // Should not throw if MaxStatements is not exceeded.
22
+ new Engine ( cfg => cfg . MaxStatements ( 3 ) ) . Execute ( script ) ;
23
+
24
+ // Should throw if MaxStatements is exceeded.
25
+ Assert . Throws < StatementsCountOverflowException > (
26
+ ( ) => new Engine ( cfg => cfg . MaxStatements ( 2 ) ) . Evaluate ( script )
27
+ ) ;
28
+ }
29
+
16
30
[ Fact ]
17
31
public void ShouldThrowMemoryLimitExceeded ( )
18
32
{
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ internal MaxStatementsConstraint(int maxStatements)
18
18
19
19
public override void Check ( )
20
20
{
21
- if ( MaxStatements > 0 && _statementsCount ++ > MaxStatements )
21
+ if ( MaxStatements > 0 && ++ _statementsCount > MaxStatements )
22
22
{
23
23
ExceptionHelper . ThrowStatementsCountOverflowException ( ) ;
24
24
}
You can’t perform that action at this time.
0 commit comments