-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move TNumberProperty validValues to TProperty #159
Comments
Also, I noticed that |
I wrote a rough draft of this and to test it I went to add qunit tests, but ran into trouble because we cannot currently include TNumber in axon unit tests. Not sure if I should change axon unit tests to require phet-io (would make it difficult for non-phetio users to test axon) or move the unit tests to an inferior location. |
Adding a dependency from axon unit => phet-io would also introduce a dependency from scenery unit tests on phet-io. @jonathanolson is this acceptable or should it be avoided? |
I thought I could add shims and what not to get things working (by overriding tandem.addInstance and creating a fake TType), but ifphetio requires Anyways, here is a unit test I decided not to commit that exercises and tests TProperty.toStateObject: var TType = function() {};
TType.toStateObject = function( instance ) {
return instance;
};
TType.fromStateObject = function( stateObject ) {
return stateObject;
};
TType.typeName = 'TType';
test( 'Test TProperty toStateObject/fromStateObject', function() {
var tandem = new phet.tandem.Tandem( 'test' );
tandem.addInstance = function( instance, type, objectk ) {
var stateObject = type.toStateObject( instance );
equal( stateObject.value, 0, 'toStateObject should match' );
debugger;
};
var property = new phet.axon.Property( 0, {
phetioValueType: TType,
tandem: tandem,
validValues: [ 0, 1, 2, 3 ]
} );
} ); |
@samreid that commit looks very good. How should we proceed about phet-io in unit tests? |
There was one problem addressed in https://github.com/phetsims/phet-io/issues/1246 |
It seems like a question for the development team about how to run phet-io specific tests for common code repos like axon/dot/kite/scenery. Should we have two test harnesses for each repo, one with phet-io and one without? Or since our team is the only one running unit tests at the moment, just require phet-io for the unit tests? The latter would be simple, but unit tests would crash for anyone who couldn't checkout the private phet-io repo. |
@samreid said:
The question is more general - it applies to phet-io unit tests for all repositories. All unit tests (phet-io and others) should be run automatically on bayes. Unit tests should be runnable from build tools, so that we can easily perform relevant unit tests before commits/builds/etc. And unit tests should be run automatically as part of an RC or production build.
I don't have a preference as to whether phet-io unit tests should be kept separate from other unit tests. That seems like a management decision, based on relative cost of separate-vs-integrated, and whether unit tests (and tools that use those tests) need to be runnable by third parties. |
PhET Development Overview contains instructions about how to build sims, and there have been related inquires on Google Group. So third parties have been using build tools. |
11/9/17 dev meeting notes: |
Overall developers in today's meeting don't feel like many people use our build tools/ support libraries outside of phet. That being said it is a big step to force phet-io into all of those repos. For now we are going to try to conditionally add phet-io tests to the same qunit test for a repo like axon. If you try to load the phet-io script but get a 404 (since our private repos aren't checked out) then it would skip the phet-io unit tests. We were also thinking that then it would be good for bayes to be adapted to run in another testing environment such does all the same tests, but without any private repos checked out. This would be a good step to take to make sure that our open source project remains usable by outside devs Consensus from @ariel-phet: Implement conditional phet-io unit tests, then lets touch base about adapting bayes to test without private repos checked out. |
I refined the unit test to this point: var TType = function() {};
TType.toStateObject = function( instance ) {
return instance;
};
TType.fromStateObject = function( stateObject ) {
return stateObject;
};
TType.typeName = 'TType';
test( 'Test TProperty toStateObject/fromStateObject', function() {
var tandem = {};
tandem.addInstance = function( instance, type, object ) {
debugger;
var stateObject = type.toStateObject( instance );
equal( stateObject.value, 0, 'toStateObject should match' );
};
var property = new axon.Property( 0, {
phetioValueType: TType,
tandem: tandem,
validValues: [ 0, 1, 2, 3 ]
} );
} ); But it's still not working because the |
Still hesitant to include |
Rather than adding I see var brand = window.phet && window.phet.chipper && window.phet.chipper.brand;
if ( brand === 'phet-io' ) {
require( [ id ], load );
}
else {
/* no op function */
} But what if we added to the condition like |
@zepumph wrote: Testing brand to determine whether to do something related to PhET-iO is an anti-pattern. The 'phet-io' brand is currently the only brand that has PhET-iO features. That will not necessarily be true in the future; other brands may have phet-io feature and should run phet-io unit tests. |
I created a new issue in the PhET-iO repo focused on how to test common code repo PhET-iO things. This issue will remain focused on "Move TNumberProperty validValues to TProperty" and on hold until we can add tests for it. |
Added unit test in preceding commit, closing. |
No description provided.
The text was updated successfully, but these errors were encountered: