<commit_before>USING: tools.test namespaces assocs alien.syntax kernel
compiler.errors accessors alien alien.c-types alien.strings
debugger literals ;
FROM: alien.libraries => add-library load-library ;
IN: compiler.tests.linkage-errors

! Regression: calling an undefined function would raise a protection fault
FUNCTION: void this_does_not_exist ( ) ;

[ this_does_not_exist ] try

[ this_does_not_exist ] [
    { "kernel-error" 9 $[ "this_does_not_exist" string>symbol ] f }
    =
] must-fail-with

[ T{ no-such-symbol { name "this_does_not_exist" } } ]
[ \ this_does_not_exist linkage-errors get at error>> ] unit-test

<< "no_such_library" "no_such_library" cdecl add-library >>

LIBRARY: no_such_library

FUNCTION: void no_such_function ( ) ;

[ no_such_function ] try

[ no_such_function ] [
    {
        "kernel-error" 9
        $[ "no_such_function" string>symbol ]
        $[ "no_such_library" load-library ]
    }
    =
] must-fail-with

[ T{ no-such-library { name "no_such_library" } } ]
[ \ no_such_function linkage-errors get at error>> ] unit-test<commit_msg>Fix linkage-errors tests for recent changes<commit_after>USING: tools.test namespaces assocs alien.syntax kernel
compiler.errors accessors alien alien.c-types alien.strings
debugger literals ;
FROM: alien.libraries => add-library load-library ;
IN: compiler.tests.linkage-errors

! Regression: calling an undefined function would raise a protection fault
FUNCTION: void this_does_not_exist ( ) ;

[ this_does_not_exist ] try

[ this_does_not_exist ] [
    { "kernel-error" 9 $[ "this_does_not_exist" string>symbol ] f }
    =
] must-fail-with

[ T{ no-such-symbol { name "this_does_not_exist" } } ]
[
    \ this_does_not_exist linkage-errors get at error>>
    ! We don't care about the error message from dlerror, just
    ! wipe it out
    f >>message
] unit-test

<< "no_such_library" "no_such_library" cdecl add-library >>

LIBRARY: no_such_library

FUNCTION: void no_such_function ( ) ;

[ no_such_function ] try

[ no_such_function ] [
    {
        "kernel-error" 9
        $[ "no_such_function" string>symbol ]
        $[ "no_such_library" load-library ]
    }
    =
] must-fail-with

[ T{ no-such-library { name "no_such_library" } } ]
[
    \ no_such_function linkage-errors get at error>>
    ! We don't care about the error message from dlerror, just
    ! wipe it out
    clone f >>message
] unit-test
{'fraction_non_alphanumeric': 0.10753138075313808, 'fraction_numerical': 0.0016736401673640166, 'mean_word_length': 3.744047619047619, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7047413', 'n_tokens_mistral': 810, 'n_tokens_neox': 794, 'n_words': 195}