Skip to content

Add test for casting after a clean or soft cast #4201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added jbmc/regression/jbmc/generic_base_type/Base.class
Binary file not shown.
21 changes: 21 additions & 0 deletions jbmc/regression/jbmc/generic_base_type/Base.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

public class Base<T> { }

class Test<T> extends Base<T> {

public void main(boolean unknown) {

if(unknown)
callee(getSpecialisedTest());
else
callee2(getUnspecialisedTest());

}

public Test<String> getSpecialisedTest() { return new Test<String>(); }
public Test<T> getUnspecialisedTest() { return new Test<T>(); }

public void callee(Base<String> b) { assert false; }
public void callee2(Base<T> b) { assert false; }

}
Binary file added jbmc/regression/jbmc/generic_base_type/Test.class
Binary file not shown.
10 changes: 10 additions & 0 deletions jbmc/regression/jbmc/generic_base_type/check_casts.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
Test.class
--function Test.main --show-goto-functions
^EXIT=0$
^SIGNAL=0$
this \. Test\.callee:\(LBase;\)V\(\(struct Base \*\)&return_tmp0->@Base\);
this \. Test\.callee2:\(LBase;\)V\(&return_tmp1->@Base\);
--
callee has a qualified Base type, and so requires a cast.
callee2 has the unqualified type that Test<T> naturally inherits, so no cast is required.
10 changes: 10 additions & 0 deletions jbmc/regression/jbmc/generic_base_type/ensure_runs.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
Test.class
--function Test.main
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
\[java::Test\.callee:\(LBase;\)V\.assertion\.1\] line 18 assertion at file Base\.java line 18 function java::Test\.callee:\(LBase;\)V bytecode-index 5: FAILURE
\[java::Test\.callee2:\(LBase;\)V\.assertion\.1\] line 19 assertion at file Base\.java line 19 function java::Test\.callee2:\(LBase;\)V bytecode-index 5: FAILURE
--
^warning: ignoring