You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
2.3 KiB
149 lines
2.3 KiB
/*
|
|
* 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();
|
|
}
|
|
}
|
|
}
|
|
}
|