|
Boost : |
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-09-23 16:20:33
Larry Evans wrote:
> On 09/23/2004 02:35 PM, Hartmut Kaiser wrote:
> [snip]
>
>> My point wasn't the concrete syntax, this is volatile at this stage
>> anyway.
>> My point was the concept to implement a library, which is 'dual' to
>> Spirit,
>> based on the idea, that a grammar describes all possible matchable input
>> sequences, so why not use this 'grammar' to specify, how to generate this
>> input sequences.
>
> Also, couldn't these 'dual' libraries be used to generate test cases
> for each other?
Sure. This would be good for performing a feature-by-feature comparison.
Hooking the machinery into Boost.Test would be a good way of getting the
results. Naturally, the test cases for each library should pass their
own tests on supported platforms; the interesting cases will be the test
cases from the other libraries.
How do we implement the tests? I suggest that we split the information into:
[1] the data type (type) being formatted, e.g. std::map< std::string,
std::string > with the details of its contents;
[2] for output -- the string (str) such that:
type val = ...;
ostringstream ss;
ss << some_fn( val );
BOOST_TEST( ss.str() == str );
[3] for input, the string (str) such that:
type val = ...;
type read;
istringstream ss( str );
ss >> some_fn( read );
BOOST_TEST( is_equal( read, val ));
where
is_equal( const T & a, const T & b )
returns true iff a == b.
This would then provide a basis for comparison between the libraries,
including: does the library support formatting of this form? and what
are the differences in the code used to perform the formatting? For example:
// review-style outfmt:
ss << io::formatob( vec. io::containerfmt().format( "< ", " >" ));
// new-style outfmt:
ss << io::object( vec. fmt::container().decorate( "< ", " >" ));
// Volodya-style outfmt:
ss << io::object( vec, "< " + fmt::container() + " >" );
// Torjo-style outfmt:
// note: $ is used because it would be infrequently used as
// part of a decoration (escape = '\$')
ss << io::object( vec, fmt::container()( "< $*$ >" ));
// decoration-on-stream outfmt:
ss << cdecorate( "< ", " >" )
<< io::object( vec, fmt::container());
// type deduction in outfmt:
ss << io::object( vec ).decorate( "< ", " >" );
Regards,
Reece
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk