diff --git a/test/builtin_split_by_characters.py b/test/builtin_split_by_characters.py new file mode 100755 index 000000000..f28ff4e3f --- /dev/null +++ b/test/builtin_split_by_characters.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +# Copyright 2012. Jurko Gospodnetic +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +# This tests the SPLIT_BY_CHARACTERS rule. + +import BoostBuild + +def test_invalid(params, expected_error_line): + t = BoostBuild.Tester(pass_toolset=0) + t.write("file.jam", "SPLIT_BY_CHARACTERS %s ;\n" % params) + t.run_build_system("-ffile.jam", status=1) + t.expect_output_line("[*] %s" % expected_error_line) + t.cleanup() + +def test_valid(): + t = BoostBuild.Tester(pass_toolset=0) + t.write("jamroot.jam", +"""import assert ; + +assert.result FooBarBaz : SPLIT_BY_CHARACTERS FooBarBaz : "" ; +assert.result FooBarBaz : SPLIT_BY_CHARACTERS FooBarBaz : x ; +assert.result FooBa Baz : SPLIT_BY_CHARACTERS FooBarBaz : r ; +assert.result FooBa Baz : SPLIT_BY_CHARACTERS FooBarBaz : rr ; +assert.result FooBa Baz : SPLIT_BY_CHARACTERS FooBarBaz : rrr ; +assert.result FooB rB z : SPLIT_BY_CHARACTERS FooBarBaz : a ; +assert.result FooB B z : SPLIT_BY_CHARACTERS FooBarBaz : ar ; +assert.result ooBarBaz : SPLIT_BY_CHARACTERS FooBarBaz : F ; +assert.result FooBarBa : SPLIT_BY_CHARACTERS FooBarBaz : z ; +assert.result ooBarBa : SPLIT_BY_CHARACTERS FooBarBaz : Fz ; +assert.result F B rB z : SPLIT_BY_CHARACTERS FooBarBaz : oa ; +assert.result Alib b : SPLIT_BY_CHARACTERS Alibaba : oa ; +assert.result libaba : SPLIT_BY_CHARACTERS Alibaba : oA ; +assert.result : SPLIT_BY_CHARACTERS FooBarBaz : FooBarBaz ; +assert.result : SPLIT_BY_CHARACTERS FooBarBaz : FoBarz ; + +# Questionable results - should they return an empty string or an empty list? +assert.result : SPLIT_BY_CHARACTERS "" : "" ; +assert.result : SPLIT_BY_CHARACTERS "" : x ; +assert.result : SPLIT_BY_CHARACTERS "" : r ; +assert.result : SPLIT_BY_CHARACTERS "" : rr ; +assert.result : SPLIT_BY_CHARACTERS "" : rrr ; +assert.result : SPLIT_BY_CHARACTERS "" : oa ; +""") + t.run_build_system() + t.cleanup() + +test_invalid("", "missing argument string") +test_invalid("Foo", "missing argument delimiters") +test_invalid(": Bar", "missing argument string") +test_invalid("a : b : c", "extra argument c") +test_invalid("a b : c", "extra argument b") +test_invalid("a : b c", "extra argument c") +test_valid() diff --git a/test/test_all.py b/test/test_all.py index a4105e099..df392ff74 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -132,6 +132,7 @@ tests = [ "absolute_sources", "build_no", "builtin_echo", "builtin_exit", + "builtin_split_by_characters", "c_file", "chain", "clean",