forked from facebook/infer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed By: cristianoc Differential Revision: D4237318 fbshipit-source-id: 3b73a64
- Loading branch information
Andrzej Kotulski
authored and
Facebook Github Bot
committed
Nov 28, 2016
1 parent
2810740
commit b0a0fbc
Showing
3 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java
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,148 @@ | ||
/* | ||
* Copyright (c) 2013 - present Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
package codetoanalyze.java.checkers; | ||
|
||
|
||
class TraceCallSequence { | ||
static void begin() { | ||
} | ||
|
||
static void end() { | ||
} | ||
|
||
static void beginWrapper() { | ||
begin(); | ||
} | ||
|
||
static void endWrapper() { | ||
end(); | ||
} | ||
|
||
void thereIsNoEnd() { | ||
begin(); | ||
} // 1 missing end/stop | ||
|
||
void thereIsNoBeginning() { | ||
end(); // too many end/stop; | ||
} | ||
|
||
void ok() { | ||
begin(); | ||
end(); | ||
} | ||
|
||
void wrapper() { | ||
begin(); | ||
beginWrapper(); | ||
end(); | ||
endWrapper(); | ||
} | ||
|
||
void exception1(String s) { | ||
begin(); | ||
int n = s.length(); | ||
end(); | ||
} // 1 missing end/stop | ||
|
||
void exception2(String s) { | ||
int n = s.length(); | ||
begin(); | ||
end(); | ||
} | ||
|
||
void exception3(String s) { | ||
begin(); | ||
try { | ||
int n = s.length(); | ||
} finally { | ||
end(); | ||
} | ||
} | ||
|
||
void infinite(int d) { | ||
int count = 0; | ||
begin(); | ||
begin(); | ||
while (count < d) { | ||
end(); | ||
begin(); | ||
count++; | ||
} | ||
end(); | ||
end(); | ||
} | ||
|
||
void nondet(int x) { | ||
if (x > 0) { | ||
begin(); | ||
} else { | ||
} | ||
end(); // too many end/stop | ||
} | ||
|
||
void grow(int d) { | ||
int count = 0; | ||
while (count < d) { | ||
begin(); | ||
} | ||
} // 2 missing end/stop | ||
|
||
void testBool(String s) { | ||
boolean shouldTrace = s.length() == 4; | ||
if (shouldTrace) { | ||
begin(); | ||
} | ||
|
||
if (shouldTrace) { | ||
shouldTrace = false; | ||
} else { | ||
shouldTrace = true; | ||
} | ||
|
||
if (!shouldTrace) { | ||
end(); | ||
} | ||
} | ||
|
||
void testBoolLoop1(String s) { | ||
boolean shouldTrace = true; | ||
while (s.length() == 4) { | ||
if (shouldTrace) { | ||
begin(); | ||
shouldTrace = false; | ||
} else { | ||
end(); | ||
shouldTrace = true; | ||
} | ||
} | ||
if (!shouldTrace) { | ||
end(); | ||
} | ||
} // 1 missing end/stop | ||
|
||
void testBoolLoop2(String s) { | ||
boolean shouldTrace = true; | ||
try { | ||
while (s.length() == 4) { | ||
if (shouldTrace) { | ||
begin(); | ||
shouldTrace = false; | ||
} else { | ||
end(); | ||
shouldTrace = true; | ||
} | ||
} | ||
} finally { | ||
if (!shouldTrace) { | ||
end(); | ||
} | ||
} | ||
} | ||
} |
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