52 lines
2.0 KiB
JavaScript
52 lines
2.0 KiB
JavaScript
/**
|
|
* Tests class prototype field
|
|
*
|
|
* Copyright (C) 2014 Free Software Foundation, Inc.
|
|
*
|
|
* This file is part of GNU ease.js.
|
|
*
|
|
* ease.js is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
require( 'common' ).testCase( 'proto/field/ProtoField',
|
|
{
|
|
/**
|
|
* In addition to producing a compiled field, we also support consuming
|
|
* a compiled field back into our internal representation for further
|
|
* processing (for example, this could be useful for static analysis).
|
|
* This is important---the compiled datum should be treated as opaque,
|
|
* so the only way to make practical use of it is to decompse it back
|
|
* into its internal representation.
|
|
*
|
|
* Note that there is no way to actually retrieve the internal datum
|
|
* other than compiling it; however, beacuse the compiled datum is to be
|
|
* treated as opaque, there is also no way to inspect that value after
|
|
* parsing it.
|
|
*
|
|
* Once composing a ProtoField, it is not possible to retrieve and
|
|
* analyze the raw value that composed it. In practice, this is not
|
|
* necessary.
|
|
*/
|
|
'Parsing compiled field produces equivalent representation': function()
|
|
{
|
|
var value = { foo: [ 'bar', 'baz' ] },
|
|
field = this.Sut( value ),
|
|
compiled = field.compile(),
|
|
parsed = this.Sut.parse( compiled );
|
|
|
|
this.assertDeepEqual( compiled, parsed.compile() );
|
|
},
|
|
} );
|
|
|