zeek/testing/btest/language/module.bro
Daniel Thayer 621a90d248 Add more language tests
Added tests for the conditional operator, operator precedence,
modules ("module" and "export" keywords, and the "::" operator), and
for the "copy" keyword.

Also improved tests of max/min values of int, count, and double constants.
2012-08-29 17:14:03 -05:00

41 lines
911 B
Text

# @TEST-EXEC: bro %INPUT secondtestfile >out
# @TEST-EXEC: btest-diff out
# In this source file, we define a module and export some objects
module thisisatest;
export {
global test_case: function(msg: string, expect: bool);
global testevent: event(msg: string);
global num: count = 123;
const daysperyear: count = 365;
}
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
event testevent(msg: string)
{
test_case( "event", T );
}
# @TEST-START-FILE secondtestfile
# In this source file, we try to access each exported object from the module
event bro_init()
{
thisisatest::test_case( "function", T );
thisisatest::test_case( "global variable", thisisatest::num == 123 );
thisisatest::test_case( "const", thisisatest::daysperyear == 365 );
event thisisatest::testevent( "foo" );
}
# @TEST-END-FILE