Skip to content

Commit

Permalink
Better unit test, but still fails
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Jun 19, 2024
1 parent bd44014 commit 9199f61
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,25 @@ class CXXInferenceTest {
assertNotNull(a)
assertTrue(a.isInferred)

val b = result.records["N::B"]
val n = result.namespaces["N"]
assertNotNull(n)
assertTrue(n.isInferred)

val b = n.records["N::B"]
assertNotNull(b)
assertTrue(b.isInferred)

val c = result.records["C"]
val m = result.namespaces["M"]
assertNotNull(m)
assertTrue(m.isInferred)

val c = m.records["N::C"]
assertNotNull(c)
assertTrue(c.isInferred)

val n = result.namespaces["N"]
assertNotNull(n)
assertTrue(n.isInferred)
val d = result.records["D"]
assertNotNull(d)
assertTrue(d.isInferred)
}

@Test
Expand Down
16 changes: 12 additions & 4 deletions cpg-language-cxx/src/test/resources/cxx/inference/superclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
// You can use `clang++ -std=c++20 tricky_inference.cpp` to check, if it will compile.
#include "superclass.h"

class D : A {
class E : A {

};

class E : N::B {
class F : N::B {

class F : C {
};

namespace O {
class G : D {
// This is a very tricky case, we are in a sub-class within a namespace and
// we depend on a type with a qualified name. It could be that M::C is part of
// O and this is a partial qualified name, but the probability is higher that
// M is actually a namespace on its own.
class H : M::C {
};
};

};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ namespace N {
class B {};
};

class C {};
namespace M {
class C {};
}

class D {};

0 comments on commit 9199f61

Please sign in to comment.