Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/unit-tests/audit-failures.html

Issue 2568573002: Additional unit test for audit.js: failure cases and logging examples. (Closed)
Patch Set: Adding expected result Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>audit.js: handling failures</title>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit.js"></script>
8 </head>
9 <body>
10 <script>
11 var audit = Audit.createTaskRunner();
12
13
14 // These assertions are supposed to be failed. The WPT (testharness) fails
15 // because the assertions are failing, but the existence of expected test
16 // result makes this test pass as long as the actual and the expected match.
17 // See the expected result file to see the logging message from Audit.
18
19 // Basic assertions.
20 audit.define('basic-failure', function (task, should) {
21 task.describe('Testing basic assertion failures.');
22
23 should(function () { var foo = bar; }, 'Setting foo to bar').notThrow();
24 should(function () { var foo = 0; }).throw('ReferenceError');
25 should(3 > 5, '3 < 5').beTrue();
26 should(true).beFalse();
27 should(1).beEqualTo(2)
28 should(1).notBeEqualTo(1)
29 should(typeof 3.141592).beEqualTo('string');
Raymond Toy 2016/12/09 22:10:26 Add description: "typeof 3.14"
hongchan 2016/12/19 22:14:06 Done.
30 should(1).beGreaterThan(2);
31 should(1).beGreaterThanOrEqualTo(2);
32 should(2).beLessThan(1);
33 should(2).beLessThanOrEqualTo(1);
34
35 let oac = new OfflineAudioContext(1, 128, 44100);
36 Promise.all([
37 should(oac.decodeAudioData(), 'Start OAC rendering').beResolved(),
Raymond Toy 2016/12/09 22:10:26 'Start OAC rendering' doesn't actually describe th
hongchan 2016/12/19 22:14:06 Sorry this was a typo.
38 should(oac.startRendering()).beRejected()
39 ]).then(task.done.bind(task));
40 });
41
42
43 // Numerical assertions.
44 audit.define('numerical-failures', function (task, should) {
45 task.describe('Testing numerical assertion failures.');
46
47 should(0).beCloseTo(0.1, { threshold: 0 });
48 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49]).beConstantValueOf(5);
49 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49])
50 .beEqualToArray([1, 8, 10, 18, 6, 5, 6, 5, 123, 48]);
51 should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 3, 2]);
52 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.04);
53 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
54 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
55 absoluteThreshold: 0.02,
56 relativeThreshold: 0.1
Raymond Toy 2016/12/09 22:10:26 Add a test using only relativeThreshold and one us
hongchan 2016/12/19 22:14:06 Done.
57 });
58
59 task.done();
60 });
61
62
63 // With no argument, this executes all tasks in the order defined.
64 audit.run();
65 </script>
66 </body>
67 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698