-
Notifications
You must be signed in to change notification settings - Fork 44
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
Publicapi coverage #252
Publicapi coverage #252
Conversation
rajsite
commented
Apr 25, 2017
- Lots of JS tests for readJSON and writeJSON
- Modified TDViaParser to support quoteInfNan to be symmetrical with TDViaFormatter
- Added default print and printError behaviors (can still be overwritten with vireo.eggShell.setPrintFunction and vireo.eggShell.setPrintErrorFunction)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vireo side changes seem good.
I did not look closely at the JS tests, but I just want to say I think it's weird that all the Karma tests have explicit code (expect ...) to compare test results rather than a 'vtr' like file and generic results tester.
Yea that would be valuable if we want to validate more environments like C++, Python, LabVIEW, etc are consuming the EggShell_ReadJSON and EggShell_WriteJSON apis correctly. Seems like each environment may still want a known in memory representation against ie a LabVIEW cluster, a C++ struct, etc. Maybe there is a good approach that doesn't require encoding the result in per platform representation:
This means the JSON parser needs to create a dynamic structure that can be reflected on, couldn't use a static one like LV without VI scripting or creating the in memory representation of the tests (ruining the whole point of separating the results). The Write JSON tests are also more involved. They currently read to validate the intial value. Write a new value. Read the new value to validate the new value. Then rewrite the old value and revalidate reading the old value. The Write JSON test is then repeated for different values compared to the original value (ie with larger arrays or smaller arrays). I think you propose an interesting idea but need to experiment more with what would make a valuable generic tester for the api. Might want it to cover less (not having tests for different array write sizes) or maybe even have more tests. Something to keep in mind for the future, especially if we want to test those APIs in more language environments. |
Updated the tests to pass in PhatomJS 👍 |
@sanmut do you have any comments on this changeset? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job. Extensive test coverage !!!
Ok to submit after addressing feedback.
Do you have work items created to track the open issues listed here?
@@ -84,13 +89,29 @@ | |||
return result; | |||
} | |||
}; | |||
}, | |||
toMatchIEEE754Number: function (util, customEqualityTesters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is labeled function declaration allowed in 'strict' mode in all browser environments? Is there a different way to do this without labeled function declaration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a function declaration, this is a function expression.
function declaration:
(function () {
function mydeclaredFunction() {
};
}());
function expression assigned to var:
(function () {
var myFunctionExpression = function () {
};
}()))
;
function expression assigned to property of object:
(function () {
var myObj = {
myFunctionExpression: function () {
}
};
}());
Is labeled function declaration allowed in 'strict' mode in all browser environments?
Is there a different way to do this without labeled function declaration?
This is not a function declaration / function statement. But I agree that if it was, we shouldn't use that form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh cool, thanks for the explanation.
expect(viaAbsolutePath).toBeNonEmptyString(); | ||
// Jasmine Matchers library is not always ready in beforeAll so use jasmine core functions | ||
expect(typeof viaAbsolutePath).toBe('string'); | ||
expect(viaAbsolutePath).not.toBe(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is doing toBeNonEmptyString() preferred way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our JS tests, we are using toBeNonEmptyString and toBeEmptyString and I thought that was the convention we wanted to follow !!??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to use the most precise test we can. Some possibilities for this check from least specific to most specific:
isDefined
isString
isNonEmptyString
toMatch(/regexp/)
toEqual
toBe
In places where we can validate the exact string like the statusText is "OK" for HTTP that is as specific as we can get.
The cookies we know a subset match the cookie string.
The paths can be anything besides a non-empty string. We could maybe use (/.via/i) or something but that's unnecessarily strict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. I misunderstood.
If you read the comment it says jasmine matchers are not available yet. So we can't use toBeNonEmptyString in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a bug in the jasmine matchers library that provides all those extra function on top of jasmine's standard matchers. So far it only effects utility files like this, it has not been a problem in the test suites yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I missed the comment just above :-( . never mind.
@@ -0,0 +1,90 @@ | |||
// Autogenerated Vireo assembly file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to check the GVI test also in after this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover comment, this was a heavily hand modified file. I can remove the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was not about that. I was wondering whether you were planning to checkin GVI tests along with the other existing GVI tests after this goes in on the Vireo side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Carlos has done that as a separate task for the user story
var vireo; | ||
|
||
var testsArrayDemoViaUrl = fixtures.convertToAbsoluteFromViaTestsDir('ArrayDemo.via'); | ||
var publicApiArrayTypesOptimizedViaUrl = fixtures.convertToAbsoluteFromFixturesDir('publicapi/ArrayTypesOptimized.via'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used in any test in this file. remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
it('Double', function () { | ||
var actualJSON = vireo.eggShell.readJSON(viName, 'dataItem_NumericDouble'); | ||
var actual = JSON.parse(actualJSON); | ||
expect(actual).toBe(123.456); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this type of checking prone to failures since we are expecting the exact value and not doing something equivalent to an epsilon comparison (http://www.ni.com/white-paper/7612/en/ ). Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't the result of a mathematical operation. We are writing an IEEE754 value to memory and reading it back. We should expect exact representation serializing IEEE754 values in and out.
compare: function (actual, expected) { | ||
var result = {}; | ||
if (typeof actual === 'number' && typeof expected === 'number') { | ||
result.pass = Object.is(actual, expected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "Object.is" expect the exact same value for floating point numbers? If so, we should use that only for special floating point numbers (such as NaN, Inf, +0, etc) and then use some epsilon comparison for regular floating point numbers. I wonder if we can use toBeCloseTo matcher in Jasmine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are validating exact representations of values can be serialized and deserialized from Vireo memory. We should not be using epsilons for comparisons during these tests.
You can see above that issue #254 was created to track Craig's suggestion. Did any others need to be made? |
There was a lot of discussion so asking for re-review from @sanmut to make sure all concerns were addressed |