Boost logo

Boost-Build :

Subject: [Boost-build] SPLIT_BY_CHARACTERS built-in rule
From: Jurko Gospodnetiæ (jurko.gospodnetic_at_[hidden])
Date: 2012-05-25 07:07:30


   Hi.

   I looked into the SPLIT_BY_CHARACTERS rule and wanted to add
unit-tests for it. You can find a sketch of what I came up with at the
bottom of this post.

   The main question is: was it intended that splitting an empty string
always returns an empty list instead of an empty string? It seems
inconsistent with how non-empty strings are treated.

   If no delimiter characters are found in a non-empty string - the
whole string is returned. When no delimiter characters are found in an
empty string - an empty list is returned.

   Even more borderline - splitting an empty string over an empty
delimiters set (delimiters=""). When a non-empty string is split that
way - the whole string is returned. When an empty string is split that
way - an empty list is returned.

   Should these empty list results be changed to empty strings instead?
Or should we simply shrug the problem off, not risk breaking backward
compatibility and code the unit tests to expect empty lists in those
cases and possibly add a note to the docs?

   Best regards,
     Jurko Gospodnetiæ

------------------

import assert ;

# Invalid calls.
#ECHO [ SPLIT_BY_CHARACTERS ] ; # missing argument string
#ECHO [ SPLIT_BY_CHARACTERS Foo ] ; # missing argument delimiters
#ECHO [ SPLIT_BY_CHARACTERS : Bar ] ; # missing argument string
#ECHO [ SPLIT_BY_CHARACTERS a : b : c ] ; # extra argument c
#ECHO [ SPLIT_BY_CHARACTERS a b : c ] ; # extra argument b
#ECHO [ SPLIT_BY_CHARACTERS a : b c ] ; # extra argument c

# Valid calls.
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 : SPLIT_BY_CHARACTERS FooBarBaz : FooBarBaz ;
assert.result : SPLIT_BY_CHARACTERS FooBarBaz : FoBarz ;

# Questionable results - should they return an empty string?
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 ;

------------------


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk