Skip to content

Commit 5f0c701

Browse files
Nathan PhillipsNathan Phillips
Nathan Phillips
authored and
Nathan Phillips
committed
Unit test to demonstrate issue in make_object_get_class_code
1 parent 20eaf21 commit 5f0c701

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package java.lang;
2+
3+
class Class {
4+
static Class forName(String className) {
5+
return null;
6+
}
7+
}
8+
9+
public class TestObjectGetClass {
10+
void main() {
11+
this.getClass();
12+
}
13+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/// file
2+
/// Test for types in return value of make_object_get_class_code
3+
4+
/// Author: Diffblue Ltd.
5+
6+
#include <testing-utils/catch.hpp>
7+
#include <util/symbol_table.h>
8+
#include <testing-utils/load_java_class.h>
9+
#include <testing-utils/free_form_cmdline.h>
10+
#include <java_bytecode/java_bytecode_language.h>
11+
12+
TEST_CASE("Check types of return value of make_object_get_class_code")
13+
{
14+
GIVEN("A class that uses getClass")
15+
{
16+
WHEN("String refinement is turned on")
17+
{
18+
free_form_cmdlinet command_line;
19+
command_line.add_flag("refine-strings");
20+
symbol_tablet symbol_table =
21+
load_java_class("TestObjectGetClass", ".", "", new_java_bytecode_language(), command_line);
22+
THEN("The type of the returned expression is that of refined strings")
23+
{
24+
for(auto &named_symbol : symbol_table.symbols)
25+
{
26+
named_symbol.first;
27+
}
28+
}
29+
//code_typet::parametert param;
30+
//param.set_identifier("this");
31+
//code_typet type;
32+
//type.parameters().push_back(param);
33+
//source_locationt loc;
34+
//loc.
35+
//symbol_tablet symbol_table;
36+
//THEN("The type of the returned expression is that of refined strings")
37+
//{
38+
// code_for_function("java::java.lang.Object.getClass:()Ljava/lang/Class;", type, loc, symbol_table);
39+
// REQUIRE(string_expr.id() == ID_struct);
40+
//}
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)