Skip to content

Commit

Permalink
[tests] fix tests for open source
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 2 deletions.
148 changes: 148 additions & 0 deletions infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java
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();
}
}
}
}
1 change: 0 additions & 1 deletion infer/tests/codetoanalyze/objc/errors/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ INFERPRINT_OPTIONS = --issues-tests

SOURCES_DEFAULT = \
field_superclass/B.m \
memory_leaks_benchmark/FBViewExample.m \
memory_leaks_benchmark/MemoryLeakRaii.m \
memory_leaks_benchmark/NSMakeCollectableExample.m \
memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m \
Expand Down
1 change: 0 additions & 1 deletion infer/tests/codetoanalyze/objc/errors/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZer
codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZero2, 2, DIVIDE_BY_ZERO, [start of procedure shouldThrowDivideByZero2(),start of procedure init,return from a call to Base_init,start of procedure returnsZero2(),Condition is false,return from a call to returnsZero2]
codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZero3, 3, DIVIDE_BY_ZERO, [start of procedure shouldThrowDivideByZero3(),start of procedure init,return from a call to Derived_init,Condition is true]
codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m, PrematureNilTermA_nilInArrayWithObjects, 5, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure nilInArrayWithObjects]
codetoanalyze/objc/errors/memory_leaks_benchmark/FBViewExample.m, FBV_main, 2, PRECONDITION_NOT_MET, [start of procedure main,start of procedure headerView,Condition is false,return from a call to FBV_headerView]
codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m, StringInitA_macForIV:, 2, MEMORY_LEAK, [start of procedure macForIV:]
codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m, createURLQueryStringBodyEscaping, 6, PRECONDITION_NOT_MET, [start of procedure createURLQueryStringBodyEscaping(),Condition is true]
codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m, createURLQueryStringBodyEscaping, 11, UNINITIALIZED_VALUE, [start of procedure createURLQueryStringBodyEscaping(),Condition is false]
Expand Down

0 comments on commit b0a0fbc

Please sign in to comment.