James F. Korsh

30 papers A 1Journal 28
YearRankTypeTitle / Venue / Authors
2011 J jnl
Comput. J.
James F. Korsh
2006 J jnl
ACM Trans. Algorithms
James F. Korsh, Paul LaFollette
2006 J jnl
Comput. J.
James F. Korsh
2005 J jnl
Comput. J.
James F. Korsh
2004 J jnl
Inf. Process. Lett.
James F. Korsh, Paul LaFollette
2004 J jnl
Comput. J.
James F. Korsh, Paul LaFollette
2003 J jnl
Int. J. Comput. Math.
James F. Korsh, Paul LaFollette, Seymour Lipschutz
2003 J jnl
Comput. J.
James F. Korsh, Paul LaFollette
2002 J jnl
Order
James F. Korsh, Paul LaFollette
2002 J jnl
Comput. J.
James F. Korsh, Paul LaFollette
2001 J jnl
Discret. Math.
James F. Korsh
2000 J jnl
Order
Paul LaFollette, James F. Korsh
2000 J jnl
J. Vis. Lang. Comput.
Paul LaFollette, James F. Korsh, Raghvinder S. Sangwan
2000 J jnl
J. Algorithms
James F. Korsh, Paul LaFollette
1999 J jnl
Inf. Process. Lett.
James F. Korsh, Paul LaFollette
1998 A conf
SIGCSE
Raghvinder S. Sangwan, James F. Korsh, Paul LaFollette
1998 J jnl
Inf. Process. Lett.
James F. Korsh, Seymour Lipschutz
1997 J jnl
J. Algorithms
James F. Korsh, Seymour Lipschutz
1994 J jnl
Inf. Process. Lett.
James F. Korsh
1993 J jnl
Inf. Process. Lett.
James F. Korsh
1984 ed.
ACM Conference on Computer Science
Frank L. Friedman, James F. Korsh
1983 J jnl
Commun. ACM
James F. Korsh, Gary Laison
1982 J jnl
Inf. Process. Lett.
James F. Korsh
1981 J jnl
Inf. Process. Lett.
James F. Korsh
1977 J jnl
Oper. Res.
Giorgio P. Ingargiola, James F. Korsh
1976 J jnl
J. ACM
Lena Chang, James F. Korsh
1975 J jnl
Oper. Res.
Giorgio P. Ingargiola, James F. Korsh
1974 J jnl
J. ACM
Giorgio P. Ingargiola, James F. Korsh
1973 J jnl
Inf. Control.
James F. Korsh
1970 J jnl
Inf. Control.
James F. Korsh
tests/unit/test_decompile_function_type.py
← Index tests/unit/test_decompile_function_type.py python
"""Unit tests for bninja/function_type.py."""
import sys
import pytest
from unittest.mock import MagicMock

# Install binaryninja stubs before importing
from tests.unit.conftest_binja_stubs import install_binja_stubs, SymbolType
install_binja_stubs()

from redb.extractors.decompiler.bninja.function_type import (
    FunctionType,
    FunctionTypeAnalysis,
)


# ============================================================================
# 4a. FunctionType / FunctionTypeAnalysis
# ============================================================================


class TestFunctionTypeEnum:
    def test_function_type_enum_values(self):
        assert FunctionType.USER.value == "USER"
        assert FunctionType.LIBRARY.value == "LIBRARY"
        assert FunctionType.EXTERNAL.value == "EXTERNAL"
        assert FunctionType.THUNK.value == "THUNK"
        assert FunctionType.UNKNOWN.value == "UNKNOWN"


class TestFunctionTypeAnalysis:
    def _make_function(self, symbol_type=None, is_thunk=False, raise_on_symbol=False):
        func = MagicMock()
        func.is_thunk = is_thunk
        if raise_on_symbol:
            type(func).symbol = property(lambda self: (_ for _ in ()).throw(Exception("no symbol")))
        else:
            func.symbol.type = symbol_type if symbol_type is not None else SymbolType.FunctionSymbol
        return func

    def test_user_function_type(self):
        func = self._make_function(symbol_type=SymbolType.FunctionSymbol)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.USER

    def test_external_function_type(self):
        func = self._make_function(symbol_type=SymbolType.ImportedFunctionSymbol)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.EXTERNAL

    def test_library_function_type(self):
        func = self._make_function(symbol_type=SymbolType.LibraryFunctionSymbol)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.LIBRARY

    def test_thunk_function_type(self):
        # Thunk overrides the symbol type
        func = self._make_function(
            symbol_type=SymbolType.FunctionSymbol, is_thunk=True
        )
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.THUNK

    def test_exception_returns_unknown(self):
        func = self._make_function(raise_on_symbol=True)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.UNKNOWN