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

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: Simplify containValues() algorithm and error message 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 // The task runner will print out a console message to ensure the text file
12 // comparison.
13 var audit = Audit.createTaskRunner({ requireResultFile: true });
14
15
16 // These assertions are supposed to be failed. The WPT (testharness) fails
17 // because the assertions are failing, but the existence of expected test
18 // result makes this test pass as long as the actual and the expected match.
19 // See the expected result file to see the logging message from Audit.
20
21
22 // Basic assertions.
23 audit.define('basic-failure', function (task, should) {
24 task.describe('Testing basic assertion failures.');
25
26 should(function () { var foo = bar; }, 'Setting foo to bar').notThrow();
27 should(function () { var foo = 0; }).throw('ReferenceError');
28 should(3 > 5, '3 < 5').beTrue();
29 should(true).beFalse();
30 should(1).beEqualTo(2)
31 should(1).notBeEqualTo(1)
32 should(typeof 3.141592, 'typeof 3.141592').beEqualTo('string');
33 should(1).beGreaterThan(2);
34 should(1).beGreaterThanOrEqualTo(2);
35 should(2).beLessThan(1);
36 should(2).beLessThanOrEqualTo(1);
37
38 let oac = new OfflineAudioContext(1, 128, 44100);
39 Promise.all([
40 should(oac.decodeAudioData(), 'Decoding audio data with no argument')
41 .beResolved(),
42 should(oac.startRendering()).beRejected()
43 ]).then(task.done.bind(task));
44 });
45
46
47 // Numerical assertions.
48 audit.define('numerical-failures', function (task, should) {
49 task.describe('Testing numerical assertion failures.');
50
51 should(0).beCloseTo(0.1, { threshold: 0 });
52 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49]).beConstantValueOf(5);
53 should([1, 8, 11, 18, 6, 5, 5, 5, 123, 49])
54 .beEqualToArray([1, 8, 10, 18, 6, 5, 6, 5, 123, 48]);
55 should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 3, 2]);
56 should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.04);
57 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
58 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
59 absoluteThreshold: 0.02
60 });
61 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
62 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
63 relativeThreshold: 0.1
64 });
65 should([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9])
66 .beCloseToArray([0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], {
67 absoluteThreshold: 0.02,
68 relativeThreshold: 0.1
69 });
70
71 task.done();
72 });
73
74
75 // With no argument, this executes all tasks in the order defined.
76 audit.run();
77 </script>
78 </body>
79 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698