Reviewed By: cristianoc Differential Revision: D4237318 fbshipit-source-id: 3b73a64master
parent
2810740377
commit
b0a0fbcc35
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue