Difference between revisions of "OSD600 and DPS909 Winter 2018 Lab 4"
(→3. Blog) |
(→3. Blog) |
||
Line 152: | Line 152: | ||
| Liam Newell | | Liam Newell | ||
| https://gist.github.com/hibyguy/836dd91212be43a73334a6d7d51eaca3 | | https://gist.github.com/hibyguy/836dd91212be43a73334a6d7d51eaca3 | ||
− | | | + | | http://liamnewell.me/blog/bugs/Lab4/ |
|- | |- | ||
| 20 | | 20 |
Revision as of 22:27, 20 March 2018
Contents
Contributing to Open Standards
This week we're discussing open standards, and for our lab will try writing some tests for the JavaScript (ecmascript) standard.
In order for implementors of the standard to know if they've got any bugs, a comprehensive set of tests are necessary. These tests should be something that can be run by any and all JavaScript implementations (i.e., we don't Microsoft to have their tests, Google to have their tests, Mozilla to have their tests, etc. and not share with each other). JavaScript should work the same everywhere, no matter which implementation you us.
In this Lab you will gain experience doing the following:
- reading a language standard
- running a test suite
- identifying testable aspects of the standard
- writing tests
- sharing work using gist.github.com
1. Running the Test Suite
The language is specified in https://tc39.github.io/ecma262/, and its test suite is available at https://github.com/tc39/test262.
To run the tests on your computer using node.js, follow the steps listed in https://github.com/bterlson/test262-harness#test262-harness.
When you run the tests, do all the tests pass or do any of them fail for you?
2. Become Familiar with Tests
Read the docs at https://github.com/tc39/test262/blob/master/CONTRIBUTING.md, which cover things like naming, general layout, assertions, error handling, etc.
Based on what you've just read, take a look at this test for String.prototype.toUpperCase(). See if you can make sense of the code and what it's testing.
3. Array.reverse
In JavaScript, Arrays can be reversed using the reverse()
method. It is defined in the standard at https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.reverse. Begin by reading the definition of steps in the spec.
What sort of things could you test with Array.reverse
? Based on what you read above, what sort of things need to be true about how Array.reverse
works? Try to write a few tests for things you just thought about, using what you learned in 2.
To add a new test, you can create new .js
files underneath test/
.
4. Extending the Existing Tests
There are actually tests written now. You can see them in the Array.prototype.reverse() tests
There is a bug to improve these tests, based on things learned while writing the TypedArray.prototype.reverse tests.
Take a look at the code for the TypedArray.prototype.reverse tests and compare it to what is happening in the Array.prototype.reverse() tests.
Can you figure out some things you could change (i.e., ideas to borrow from the other tests)? Try rewriting some of the tests for Array.reverse
to do what you think might be better.
NOTE: you do not need to submit your tests. This lab is only about reading the spec and existing tests, and understanding how they work.
3. Blog
Write a blog post about your experience reading the spec and tests and trying to write new tests. Put any code that you wrote into a gist on GitHub (i.e., you don't need to do a pull request or submit them anywhere).
Please add a line for your blog in the following table: