|
@@ -1,5 +1,8 @@
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
+import itertools
|
|
|
+from typing import Iterable
|
|
|
+
|
|
|
import itanium_demangler as dm
|
|
|
import pytest
|
|
|
import smgdc.demangler_helpers as dh
|
|
@@ -90,3 +93,42 @@ def test_function_in_virtual_class(input_vtsym: str, input_fnsym: str, expected:
|
|
|
def test_function_match_signature(fnsym_a: str, fnsym_b: str, expected: bool):
|
|
|
sig_a, sig_b = map(dh.extract_method_signature, map(dm.parse, (fnsym_a, fnsym_b)))
|
|
|
assert expected == (sig_a == sig_b)
|
|
|
+
|
|
|
+
|
|
|
+@pytest.mark.parametrize(
|
|
|
+ "fnsyms,expected",
|
|
|
+ [
|
|
|
+ (
|
|
|
+ # PASS: same class, same name, differing parameter types
|
|
|
+ (
|
|
|
+ "_ZN11CBaseEntity8KeyValueEPKcS1_",
|
|
|
+ "_ZN11CBaseEntity8KeyValueEPKcf",
|
|
|
+ "_ZN11CBaseEntity8KeyValueEPKcRK6Vector",
|
|
|
+ ),
|
|
|
+ True,
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ # PASS: same class, same name, differing parameter types
|
|
|
+ (
|
|
|
+ "_ZN24CTFWeaponBaseGrenadeProj11InitGrenadeERK6VectorS2_P20CBaseCombatCharacterRK13CTFWeaponInfo",
|
|
|
+ "_ZN24CTFWeaponBaseGrenadeProj11InitGrenadeERK6VectorS2_P20CBaseCombatCharacterif",
|
|
|
+ ),
|
|
|
+ True,
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ # PASS: different class, same name, differing parameter types
|
|
|
+ (
|
|
|
+ "_ZN20CBaseCombatCharacter8FVisibleEP11CBaseEntityiPS1_",
|
|
|
+ "_ZN11CBaseEntity8FVisibleERK6VectoriPPS_",
|
|
|
+ ),
|
|
|
+ True,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+)
|
|
|
+def test_function_overloaded(fnsyms: Iterable[str], expected: bool):
|
|
|
+ """
|
|
|
+ Tests that all the given symbols are overloads of the same name.
|
|
|
+ Of course, this is only inference based on symbol name.
|
|
|
+ """
|
|
|
+ node_syms = map(dh.extract_method_fname, map(dm.parse, fnsyms))
|
|
|
+ assert all(a == b for a, b in itertools.permutations(node_syms, 2))
|