| OLD | NEW |
| 1 if (window.testRunner) | 1 if (window.testRunner) |
| 2 testRunner.overridePreference("WebKitWebAudioEnabled", "1"); | 2 testRunner.overridePreference("WebKitWebAudioEnabled", "1"); |
| 3 | 3 |
| 4 function writeString(s, a, offset) { | 4 function writeString(s, a, offset) { |
| 5 for (var i = 0; i < s.length; ++i) { | 5 for (var i = 0; i < s.length; ++i) { |
| 6 a[offset + i] = s.charCodeAt(i); | 6 a[offset + i] = s.charCodeAt(i); |
| 7 } | 7 } |
| 8 } | 8 } |
| 9 | 9 |
| 10 function writeInt16(n, a, offset) { | 10 function writeInt16(n, a, offset) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 for (var i = 1; i <= numChannels; i++) { | 354 for (var i = 1; i <= numChannels; i++) { |
| 355 var data = buffer.getChannelData(i-1); | 355 var data = buffer.getChannelData(i-1); |
| 356 for (var j = 0; j < data.length; j++) { | 356 for (var j = 0; j < data.length; j++) { |
| 357 // Storing channel index into the channel buffer. | 357 // Storing channel index into the channel buffer. |
| 358 data[j] = i; | 358 data[j] = i; |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 return buffer; | 361 return buffer; |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Compute the (linear) signal-to-noise ratio between |actual| and |expected|.
The result is NOT in |
| 365 // dB! If the |actual| and |expected| have different lengths, the shorter lengt
h is used. |
| 366 function computeSNR(actual, expected) |
| 367 { |
| 368 var signalPower = 0; |
| 369 var noisePower = 0; |
| 370 |
| 371 var length = Math.min(actual.length, expected.length); |
| 372 |
| 373 for (var k = 0; k < length; ++k) { |
| 374 var diff = actual[k] - expected[k]; |
| 375 signalPower += expected[k] * expected[k]; |
| 376 noisePower += diff * diff; |
| 377 } |
| 378 |
| 379 return signalPower / noisePower; |
| 380 } |
| 364 | 381 |
| 365 // |Should| JS layout test utility. | 382 // |Should| JS layout test utility. |
| 366 // Dependency: ../resources/js-test.js | 383 // Dependency: ../resources/js-test.js |
| 367 var Should = (function () { | 384 var Should = (function () { |
| 368 | 385 |
| 369 'use strict'; | 386 'use strict'; |
| 370 | 387 |
| 371 // ShouldModel internal class. For the exposed (factory) method, it is the | 388 // ShouldModel internal class. For the exposed (factory) method, it is the |
| 372 // return value of this closure. | 389 // return value of this closure. |
| 373 function ShouldModel(desc, target, opts) { | 390 function ShouldModel(desc, target, opts) { |
| 374 this.desc = desc; | 391 this.desc = desc; |
| 375 this.target = target; | 392 this.target = target; |
| 393 // |_testPassed| and |_testFailed| set this appropriately. |
| 394 this.success = false; |
| 376 | 395 |
| 377 // If the number of errors is greater than this, the rest of error | 396 // If the number of errors is greater than this, the rest of error |
| 378 // messages are suppressed. the value is fairly arbitrary, but shouldn't | 397 // messages are suppressed. the value is fairly arbitrary, but shouldn't |
| 379 // be too small or too large. | 398 // be too small or too large. |
| 380 this.NUM_ERRORS_LOG = opts.numberOfErrorLog; | 399 this.NUM_ERRORS_LOG = opts.numberOfErrorLog; |
| 381 | 400 |
| 382 // If the number of array elements is greater than this, the rest of | 401 // If the number of array elements is greater than this, the rest of |
| 383 // elements will be omitted. | 402 // elements will be omitted. |
| 384 this.NUM_ARRAY_LOG = opts.numberOfArrayLog; | 403 this.NUM_ARRAY_LOG = opts.numberOfArrayLog; |
| 385 } | 404 } |
| 386 | 405 |
| 387 // Internal methods starting with a underscore. | 406 // Internal methods starting with a underscore. |
| 388 ShouldModel.prototype._testPassed = function (msg) { | 407 ShouldModel.prototype._testPassed = function (msg) { |
| 389 testPassed(this.desc + ' ' + msg + '.'); | 408 testPassed(this.desc + ' ' + msg + '.'); |
| 409 this._success = true; |
| 390 }; | 410 }; |
| 391 | 411 |
| 392 ShouldModel.prototype._testFailed = function (msg) { | 412 ShouldModel.prototype._testFailed = function (msg) { |
| 393 testFailed(this.desc + ' ' + msg + '.'); | 413 testFailed(this.desc + ' ' + msg + '.'); |
| 414 this._success = false; |
| 394 }; | 415 }; |
| 395 | 416 |
| 396 ShouldModel.prototype._isArray = function (arg) { | 417 ShouldModel.prototype._isArray = function (arg) { |
| 397 return arg instanceof Array || arg instanceof Float32Array; | 418 return arg instanceof Array || arg instanceof Float32Array; |
| 398 }; | 419 }; |
| 399 | 420 |
| 400 ShouldModel.prototype._assert = function (expression, reason) { | 421 ShouldModel.prototype._assert = function (expression, reason) { |
| 401 if (expression) | 422 if (expression) |
| 402 return; | 423 return; |
| 403 | 424 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 414 // "PASS Zero is equal to 0." | 435 // "PASS Zero is equal to 0." |
| 415 ShouldModel.prototype.beEqualTo = function (value) { | 436 ShouldModel.prototype.beEqualTo = function (value) { |
| 416 var type = typeof value; | 437 var type = typeof value; |
| 417 this._assert(type === 'number' || type === 'string', | 438 this._assert(type === 'number' || type === 'string', |
| 418 'value should be number or string for'); | 439 'value should be number or string for'); |
| 419 | 440 |
| 420 if (this.target === value) | 441 if (this.target === value) |
| 421 this._testPassed('is equal to ' + value); | 442 this._testPassed('is equal to ' + value); |
| 422 else | 443 else |
| 423 this._testFailed('was ' + value + ' instead of ' + this.target); | 444 this._testFailed('was ' + value + ' instead of ' + this.target); |
| 445 return this._success; |
| 424 }; | 446 }; |
| 425 | 447 |
| 426 // Check if |target| is not equal to |value|. | 448 // Check if |target| is not equal to |value|. |
| 427 // | 449 // |
| 428 // Example: | 450 // Example: |
| 429 // Should('One', one).notBeEqualTo(0); | 451 // Should('One', one).notBeEqualTo(0); |
| 430 // Result: | 452 // Result: |
| 431 // "PASS One is not equal to 0." | 453 // "PASS One is not equal to 0." |
| 432 ShouldModel.prototype.notBeEqualTo = function (value) { | 454 ShouldModel.prototype.notBeEqualTo = function (value) { |
| 433 var type = typeof value; | 455 var type = typeof value; |
| 434 this._assert(type === 'number' || type === 'string', | 456 this._assert(type === 'number' || type === 'string', |
| 435 'value should be number or string for'); | 457 'value should be number or string for'); |
| 436 | 458 |
| 437 if (this.target === value) | 459 if (this.target === value) |
| 438 this._testFailed('should not be equal to ' + value); | 460 this._testFailed('should not be equal to ' + value); |
| 439 else | 461 else |
| 440 this._testPassed('is not equal to ' + value); | 462 this._testPassed('is not equal to ' + value); |
| 463 return this._success; |
| 441 }; | 464 }; |
| 442 | 465 |
| 443 // Check if |target| is greater than or equal to |value|. | 466 // Check if |target| is greater than or equal to |value|. |
| 444 // | 467 // |
| 445 // Example: | 468 // Example: |
| 446 // Should("SNR", snr).greaterThanOrEqualTo(100); | 469 // Should("SNR", snr).beGreaterThanOrEqualTo(100); |
| 447 // Result: | 470 // Result: |
| 448 // "PASS SNR exceeds 100" | 471 // "PASS SNR exceeds 100" |
| 449 // "FAIL SNR (n) is not greater than or equal to 100" | 472 // "FAIL SNR (n) is not greater than or equal to 100" |
| 450 ShouldModel.prototype.beGreaterThanOrEqualTo = function (value) { | 473 ShouldModel.prototype.beGreaterThanOrEqualTo = function (value) { |
| 451 var type = typeof value; | 474 var type = typeof value; |
| 452 this._assert(type === 'number' || type === 'string', | 475 this._assert(type === 'number' || type === 'string', |
| 453 'value should be number or string for'); | 476 'value should be number or string for'); |
| 454 | 477 |
| 455 if (this.target >= value) | 478 if (this.target >= value) |
| 456 this._testPassed("is greater than or equal to " + value); | 479 this._testPassed("is greater than or equal to " + value); |
| 457 else | 480 else |
| 458 this._testFailed("(" + this.target + ") is not greater than or equal
to " + value); | 481 this._testFailed("(" + this.target + ") is not greater than or equal
to " + value); |
| 482 return this._success; |
| 483 } |
| 484 |
| 485 // Check if |target| is lest than or equal to |value|. |
| 486 // |
| 487 // Example: |
| 488 // maxError = 1e-6; |
| 489 // Should("max error", maxError).beLessThanOrEqualTo(1e-5); |
| 490 // Should("max error", maxError).beLessThanOrEqualTo(-1); |
| 491 // Result: |
| 492 // "PASS max error is less than or equal to 1e-5" |
| 493 // "FAIL max error (1e-6) is not less than or equal to -1" |
| 494 ShouldModel.prototype.beLessThanOrEqualTo = function (value) { |
| 495 var type = typeof value; |
| 496 this._assert(type === 'number', 'value should be number or string for'); |
| 497 |
| 498 if (this.target <= value) |
| 499 this._testPassed("is less than or equal to " + value); |
| 500 else |
| 501 this._testFailed("(" + this.target + ") is not less than or equal to
" + value); |
| 502 return this._success; |
| 459 } | 503 } |
| 460 | 504 |
| 461 // Check if |target| is close to |value| using the given relative error |thr
eshold|. | 505 // Check if |target| is close to |value| using the given relative error |thr
eshold|. |
| 462 // |value| should not be zero, but no check is made for that. | 506 // |value| should not be zero, but no check is made for that. |
| 463 // | 507 // |
| 464 // Example: | 508 // Example: |
| 465 // Should("One", 1.001).beCloseTo(1, .1); | 509 // Should("One", 1.001).beCloseTo(1, .1); |
| 466 // Should("One", 2).beCloseTo(1, .1); | 510 // Should("One", 2).beCloseTo(1, .1); |
| 467 // Result: | 511 // Result: |
| 468 // "PASS One is 1 within a relative error of 0.1." | 512 // "PASS One is 1 within a relative error of 0.1." |
| 469 // "FAIL One is not 1 within a relative error of 0.1: 2" | 513 // "FAIL One is not 1 within a relative error of 0.1: 2" |
| 470 ShouldModel.prototype.beCloseTo = function (value, relativeErrorThreshold) { | 514 ShouldModel.prototype.beCloseTo = function (value, relativeErrorThreshold) { |
| 471 var type = typeof value; | 515 var type = typeof value; |
| 472 this._assert(type === 'number', 'value should be number for'); | 516 this._assert(type === 'number', 'value should be number for'); |
| 473 | 517 |
| 474 var relativeError = Math.abs(this.target - value) / Math.abs(value); | 518 var relativeError = Math.abs(this.target - value) / Math.abs(value); |
| 475 if (relativeError <= relativeErrorThreshold) { | 519 if (relativeError <= relativeErrorThreshold) { |
| 476 this._testPassed("is " + value + " within a relative error of " + re
lativeErrorThreshold); | 520 this._testPassed("is " + value + " within a relative error of " + re
lativeErrorThreshold); |
| 477 } else { | 521 } else { |
| 478 this._testFailed("is not " + value + " within a relative error of "
+ relativeErrorThreshold | 522 this._testFailed("is not " + value + " within a relative error of "
+ relativeErrorThreshold |
| 479 + ": " + this.target); | 523 + ": " + this.target); |
| 480 } | 524 } |
| 525 return this._success; |
| 481 } | 526 } |
| 482 | 527 |
| 483 // Check if |func| throws an exception with a certain |errorType| correctly. | 528 // Check if |func| throws an exception with a certain |errorType| correctly. |
| 484 // |errorType| is optional. | 529 // |errorType| is optional. |
| 485 // | 530 // |
| 486 // Example: | 531 // Example: |
| 487 // Should('A bad code', function () { var a = b; }).throw(); | 532 // Should('A bad code', function () { var a = b; }).throw(); |
| 488 // Result: | 533 // Result: |
| 489 // "PASS A bad code threw an exception." | 534 // "PASS A bad code threw an exception." |
| 490 // Example: | 535 // Example: |
| 491 // Should('var c = d', function () { var c = d; }).throw('ReferenceError'); | 536 // Should('var c = d', function () { var c = d; }).throw('ReferenceError'); |
| 492 // "PASS var c = d threw ReferenceError." | 537 // "PASS var c = d threw ReferenceError." |
| 493 ShouldModel.prototype.throw = function (errorType) { | 538 ShouldModel.prototype.throw = function (errorType) { |
| 494 if (typeof this.target !== 'function') { | 539 if (typeof this.target !== 'function') { |
| 495 console.log('target is not a function. test halted.'); | 540 console.log('target is not a function. test halted.'); |
| 496 return; | 541 return; |
| 497 } | 542 } |
| 498 | 543 |
| 499 try { | 544 try { |
| 500 this.target(); | 545 this.target(); |
| 501 this._testFailed('did not throw an exception'); | 546 this._testFailed('did not throw an exception'); |
| 502 } catch (error) { | 547 } catch (error) { |
| 503 if (errorType === undefined) | 548 if (errorType === undefined) |
| 504 this._testPassed('threw an exception of type ' + error.name); | 549 this._testPassed('threw an exception of type ' + error.name); |
| 505 else if (error.name === errorType) | 550 else if (error.name === errorType) |
| 506 this._testPassed('threw ' + errorType + ': ' + error.message); | 551 this._testPassed('threw ' + errorType + ': ' + error.message); |
| 507 else | 552 else |
| 508 this._testFailed('threw ' + error.name + ' instead of ' + except
ion); | 553 this._testFailed('threw ' + error.name + ' instead of ' + except
ion); |
| 509 } | 554 } |
| 555 return this._success; |
| 510 }; | 556 }; |
| 511 | 557 |
| 512 // Check if |func| does not throw an exception. | 558 // Check if |func| does not throw an exception. |
| 513 // | 559 // |
| 514 // Example: | 560 // Example: |
| 515 // Should('var foo = "bar"', function () { var foo = 'bar'; }).notThrow(); | 561 // Should('var foo = "bar"', function () { var foo = 'bar'; }).notThrow(); |
| 516 // Result: | 562 // Result: |
| 517 // "PASS var foo = "bar" did not throw an exception." | 563 // "PASS var foo = "bar" did not throw an exception." |
| 518 ShouldModel.prototype.notThrow = function () { | 564 ShouldModel.prototype.notThrow = function () { |
| 519 try { | 565 try { |
| 520 this.target(); | 566 this.target(); |
| 521 this._testPassed('did not throw an exception'); | 567 this._testPassed('did not throw an exception'); |
| 522 } catch (error) { | 568 } catch (error) { |
| 523 this._testFailed('threw ' + error.name + ': ' + error.message); | 569 this._testFailed('threw ' + error.name + ': ' + error.message); |
| 524 } | 570 } |
| 571 return this._success; |
| 525 }; | 572 }; |
| 526 | 573 |
| 527 // Check if |target| array is filled with constant values. | 574 // Check if |target| array is filled with constant values. |
| 528 // | 575 // |
| 529 // Example: | 576 // Example: |
| 530 // Should('[2, 2, 2]', [2, 2, 2]).beConstantValueOf(2); | 577 // Should('[2, 2, 2]', [2, 2, 2]).beConstantValueOf(2); |
| 531 // Result: | 578 // Result: |
| 532 // "PASS [2, 2, 2] has constant values of 2." | 579 // "PASS [2, 2, 2] has constant values of 2." |
| 533 ShouldModel.prototype.beConstantValueOf = function (value) { | 580 ShouldModel.prototype.beConstantValueOf = function (value) { |
| 534 var mismatches = {}; | 581 var mismatches = {}; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 548 for (var index in mismatches) { | 595 for (var index in mismatches) { |
| 549 failureMessage += '\n[' + index + '] : ' + mismatches[index]; | 596 failureMessage += '\n[' + index + '] : ' + mismatches[index]; |
| 550 if (++counter >= this.NUM_ERRORS_LOG) { | 597 if (++counter >= this.NUM_ERRORS_LOG) { |
| 551 failureMessage += '\nand ' + (numberOfmismatches - counter)
+ | 598 failureMessage += '\nand ' + (numberOfmismatches - counter)
+ |
| 552 ' more differences...'; | 599 ' more differences...'; |
| 553 break; | 600 break; |
| 554 } | 601 } |
| 555 } | 602 } |
| 556 this._testFailed(failureMessage); | 603 this._testFailed(failureMessage); |
| 557 } | 604 } |
| 605 return this._success; |
| 558 }; | 606 }; |
| 559 | 607 |
| 560 // Check if |target| array is identical to |expected| array element-wise. | 608 // Check if |target| array is identical to |expected| array element-wise. |
| 561 // | 609 // |
| 562 // Example: | 610 // Example: |
| 563 // Should('[1, 2, 3]', [1, 2, 3]).beEqualToArray([1, 2, 3]); | 611 // Should('[1, 2, 3]', [1, 2, 3]).beEqualToArray([1, 2, 3]); |
| 564 // Result: | 612 // Result: |
| 565 // "PASS [1, 2, 3] is identical to the array [1,2,3]." | 613 // "PASS [1, 2, 3] is identical to the array [1,2,3]." |
| 566 ShouldModel.prototype.beEqualToArray = function (array) { | 614 ShouldModel.prototype.beEqualToArray = function (array) { |
| 567 this._assert(this._isArray(array) && this.target.length === array.length
, | 615 this._assert(this._isArray(array) && this.target.length === array.length
, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 586 failureMessage += '\n[' + index + '] : ' + mismatches[index]; | 634 failureMessage += '\n[' + index + '] : ' + mismatches[index]; |
| 587 if (++counter >= this.NUM_ERRORS_LOG) { | 635 if (++counter >= this.NUM_ERRORS_LOG) { |
| 588 failureMessage += '\nand ' + (numberOfmismatches - counter)
+ | 636 failureMessage += '\nand ' + (numberOfmismatches - counter)
+ |
| 589 ' more differences...'; | 637 ' more differences...'; |
| 590 break; | 638 break; |
| 591 } | 639 } |
| 592 } | 640 } |
| 593 | 641 |
| 594 this._testFailed(failureMessage); | 642 this._testFailed(failureMessage); |
| 595 } | 643 } |
| 644 return this._success; |
| 596 }; | 645 }; |
| 597 | 646 |
| 598 // Check if |target| array is close to |expected| array element-wise within | 647 // Check if |target| array is close to |expected| array element-wise within |
| 599 // the range of |maxAllowedError|. | 648 // the range of |maxAllowedError|. |
| 600 // | 649 // |
| 601 // Example: | 650 // Example: |
| 602 // Should('My array', [0.11, 0.19]).beCloseToArray([0.1, 0.2], 0.02); | 651 // Should('My array', [0.11, 0.19]).beCloseToArray([0.1, 0.2], 0.02); |
| 603 // Result: | 652 // Result: |
| 604 // "PASS My array equals [0.1,0.2] within an element-wise tolerance of 0.02.
" | 653 // "PASS My array equals [0.1,0.2] within an element-wise tolerance of 0.02.
" |
| 605 ShouldModel.prototype.beCloseToArray = function (array, maxAllowedError) { | 654 ShouldModel.prototype.beCloseToArray = function (array, maxAllowedError) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 630 failureMessage += '\n[' + index + '] : ' + mismatches[index]; | 679 failureMessage += '\n[' + index + '] : ' + mismatches[index]; |
| 631 if (++counter >= this.NUM_ERRORS_LOG) { | 680 if (++counter >= this.NUM_ERRORS_LOG) { |
| 632 failureMessage += '\nand ' + (numberOfmismatches - counter)
+ | 681 failureMessage += '\nand ' + (numberOfmismatches - counter)
+ |
| 633 ' more differences...'; | 682 ' more differences...'; |
| 634 break; | 683 break; |
| 635 } | 684 } |
| 636 } | 685 } |
| 637 | 686 |
| 638 this._testFailed(failureMessage); | 687 this._testFailed(failureMessage); |
| 639 } | 688 } |
| 689 return this._success; |
| 640 }; | 690 }; |
| 641 | 691 |
| 642 // Check if |target| array contains a set of values in a certain order. | 692 // Check if |target| array contains a set of values in a certain order. |
| 643 // | 693 // |
| 644 // Example: | 694 // Example: |
| 645 // Should('My random array', [1, 1, 3, 3, 2]).containValues([1, 3, 2]); | 695 // Should('My random array', [1, 1, 3, 3, 2]).containValues([1, 3, 2]); |
| 646 // Result: | 696 // Result: |
| 647 // "PASS My random array contains all the expected values in the correct | 697 // "PASS My random array contains all the expected values in the correct |
| 648 // order: [1,3,2]." | 698 // order: [1,3,2]." |
| 649 ShouldModel.prototype.containValues = function (expected) { | 699 ShouldModel.prototype.containValues = function (expected) { |
| 650 var indexExpected = 0, indexActual = 0; | 700 var indexExpected = 0, indexActual = 0; |
| 651 while (indexExpected < expected.length && indexActual < this.target.leng
th) { | 701 while (indexExpected < expected.length && indexActual < this.target.leng
th) { |
| 652 if (expected[indexExpected] === this.target[indexActual]) | 702 if (expected[indexExpected] === this.target[indexActual]) |
| 653 indexActual++; | 703 indexActual++; |
| 654 else | 704 else |
| 655 indexExpected++; | 705 indexExpected++; |
| 656 } | 706 } |
| 657 | 707 |
| 658 if (indexExpected < expected.length-1 || indexActual < this.target.lengt
h-1) { | 708 if (indexExpected < expected.length-1 || indexActual < this.target.lengt
h-1) { |
| 659 this._testFailed('contains an unexpected value ' + this.target[index
Actual] + | 709 this._testFailed('contains an unexpected value ' + this.target[index
Actual] + |
| 660 ' at index ' + indexActual); | 710 ' at index ' + indexActual); |
| 661 } else { | 711 } else { |
| 662 this._testPassed('contains all the expected values in the correct or
der: [' + | 712 this._testPassed('contains all the expected values in the correct or
der: [' + |
| 663 expected + ']'); | 713 expected + ']'); |
| 664 } | 714 } |
| 715 return this._success; |
| 665 }; | 716 }; |
| 666 | 717 |
| 667 // Check if |target| array does not have any glitches. Note that |threshold| | 718 // Check if |target| array does not have any glitches. Note that |threshold| |
| 668 // is not optional and is to define the desired threshold value. | 719 // is not optional and is to define the desired threshold value. |
| 669 // | 720 // |
| 670 // Example: | 721 // Example: |
| 671 // Should('Channel #0', chanL).notGlitch(0.0005); | 722 // Should('Channel #0', chanL).notGlitch(0.0005); |
| 672 // Result: | 723 // Result: |
| 673 // "PASS Channel #0 has no glitch above the threshold of 0.0005." | 724 // "PASS Channel #0 has no glitch above the threshold of 0.0005." |
| 674 ShouldModel.prototype.notGlitch = function (threshold) { | 725 ShouldModel.prototype.notGlitch = function (threshold) { |
| 675 for (var i = 1; i < this.target.length; i++) { | 726 for (var i = 1; i < this.target.length; i++) { |
| 676 var diff = Math.abs(this.target[i-1] - this.target[i]); | 727 var diff = Math.abs(this.target[i-1] - this.target[i]); |
| 677 if (diff >= threshold) { | 728 if (diff >= threshold) { |
| 678 this._testFailed('has a glitch at index ' + i + ' of size ' + di
ff); | 729 this._testFailed('has a glitch at index ' + i + ' of size ' + di
ff); |
| 679 return; | 730 return this._success; |
| 680 } | 731 } |
| 681 } | 732 } |
| 682 this._testPassed('has no glitch above the threshold of ' + threshold); | 733 this._testPassed('has no glitch above the threshold of ' + threshold); |
| 734 return this._success; |
| 683 }; | 735 }; |
| 684 | 736 |
| 685 // Should() method. | 737 // Should() method. |
| 686 // | 738 // |
| 687 // |desc| is the description of the task or check and |target| is a value | 739 // |desc| is the description of the task or check and |target| is a value |
| 688 // needs to be checked or a task to be performed. |opt| contains options for | 740 // needs to be checked or a task to be performed. |opt| contains options for |
| 689 // printing out log messages: options are |opt.numberOfErrorLog| and | 741 // printing out log messages: options are |opt.numberOfErrorLog| and |
| 690 // |opts.numberOfArrayLog|. | 742 // |opts.numberOfArrayLog|. |
| 691 return function (desc, target, opts) { | 743 return function (desc, target, opts) { |
| 692 var _opts = { | 744 var _opts = { |
| 693 numberOfErrorLog: 8, | 745 numberOfErrorLog: 8, |
| 694 numberOfArrayLog: 16 | 746 numberOfArrayLog: 16 |
| 695 }; | 747 }; |
| 696 | 748 |
| 697 if (opts instanceof Object) { | 749 if (opts instanceof Object) { |
| 698 if (opts.hasOwnProperty('numberOfErrorLog')) | 750 if (opts.hasOwnProperty('numberOfErrorLog')) |
| 699 _opts.numberOfErrorLog = opts.numberOfErrorLog; | 751 _opts.numberOfErrorLog = opts.numberOfErrorLog; |
| 700 if (opts.hasOwnProperty('numberOfArrayLog')) | 752 if (opts.hasOwnProperty('numberOfArrayLog')) |
| 701 _opts.numberOfArrayLog = opts.numberOfArrayLog; | 753 _opts.numberOfArrayLog = opts.numberOfArrayLog; |
| 702 } | 754 } |
| 703 | 755 |
| 704 return new ShouldModel(desc, target, _opts); | 756 return new ShouldModel(desc, target, _opts); |
| 705 }; | 757 }; |
| 706 | 758 |
| 707 })(); | 759 })(); |
| OLD | NEW |