PreviousUpNext

15.4.1129  src/lib/std/src/nj/interprocess-signals-unit-test.pkg

## interprocess-signals-unit-test.pkg
#
# Unit/regression test functionality for
#
#    src/lib/std/src/nj/interprocess-signals.pkg
#

# Compiled by:
#     src/lib/test/unit-tests.lib

# Run by:
#     src/lib/test/all-unit-tests.pkg


stipulate
    package ip  =  interprocess_signals;                                                                        # interprocess_signals          is from   src/lib/std/src/nj/interprocess-signals.pkg
    #
    sleep = makelib::scripting_globals::sleep;
herein

    package interprocess_signals_unit_test {
        #
        include package   unit_test;                                                                            # unit_test                     is from   src/lib/src/unit-test.pkg
 
        name =  "src/lib/std/src/nj/interprocess-signals-unit-test.pkg";
 
 
        fun verify_signal_naming_constency ()
            =
            {   # I'm mainly worried about   interprocess_signals::all_signals []
                # and kith getting out of sync with   signal_table__local []   in
                #
                #     src/c/machine-dependent/interprocess-signals.c
                #
                # so we test that stuff heavily here:

                all_signals     =  ip::all_signals;

                signals_as_ints =  map  ip::signal_to_int  all_signals;

                max_signal      =  head (reverse signals_as_ints);

                assert( signals_as_ints  ==  (1 .. max_signal) );                                               # Check that signals_as_ints is an ascending sequence 1 .. max_signal.

                signals_as_ints2  =  map' signals_as_ints  (\\ i = (ip::signal_to_int (ip::int_to_signal i)));

                assert( signals_as_ints  == signals_as_ints2 );                                                 # Check that signal_to_int() and int_to_signal() are mutual inverses.

                signal_names     =  map  ip::signal_to_string  all_signals;
                signals_as_ints3 =  map  ip::ascii_signal_name_to_portable_signal_id  signal_names;

                assert( signals_as_ints3 == signals_as_ints );                                                  # Check that   signal_table__local []   corresponds to   ip::all_signals []   etc.
                assert( ip::maximum_valid_portable_signal_id() == max_signal );                                 # "                                                                             ".

                assert( (length (map ip::signal_is_supported_by_host_os  all_signals)) == max_signal);          # Check that   ip::signal_is_supported_by_host_os   at least doesn't crash.
            };

        fun run ()
            =
            {   printf "\nDoing %s:\n" name;   
                #
                verify_signal_naming_constency ();
                #
                summarize_unit_tests  name;
            };
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext