How to use testError method in wpt

Best JavaScript code snippet using wpt

julian.py

Source:julian.py Github

copy

Full Screen

1'''2Julian day routines from Meeus, "Astronomical Formulae for Calculators".3The routines are:4 Julian(month, day, year) Integer Julian day number5 Julian1(datestring) Integer Julian day number, but6 takes string arg "YYYYMMDD"7 JulianAstro(month, day, year) Astronomical Julian day number8 JulianToDate(julian_day) Returns month, day, year tuple9 DayOfWeek(month, day, year) 0 = Sunday10 DayOfYear(month, day, year) 1 to 365 (366 in leap year)11 IsValidDate(month, day, year) Returns true if date is valid Gregorian12 IsLeapYear(year) Returns true if year is leap year13 NumDaysInMonth(month, year)14The JulianAstro function returns the astronomical form and is returned15as a floating point number. The astronomical Julian day begins at16Greenwich mean noon. The Julian() function returns the more usual17Julian day as an integer; it is gotten from the astronomical form by18adding 0.55 and taking the integer part.19'''20# Copyright (C) 1998 Don Peterson21# Contact: gmail.com@someonesdad122# 23# 24from __future__ import division, print_function25def NumDaysInMonth(month, year):26 if month == 2:27 if IsLeapYear(year):28 return 2929 else:30 return 2831 elif month == 9 or month == 4 or month == 6 or month == 11:32 return 3033 elif month == 1 or month == 3 or month == 5 or month == 7 or \34 month == 8 or month == 10 or month == 12:35 return 3136 else:37 raise "Bad month"38def DecodeDay(day):39 '''Return a tuple of (hr, min, sec) given a decimal day.40 '''41 frac = day - int(day)42 hr = int(24.*frac)43 frac -= hr/24.44 min = int(24.*60.*frac)45 frac -= min/(24.*60.)46 sec = 24.*3600.*frac47 return (hr, min, sec)48def JulianToDate(julian_day):49 '''From Meeus, "Astronomical Algorithms", pg 63.50 '''51 if julian_day < 0: raise "Bad input value"52 jd = julian_day + 0.553 Z = int(jd)54 F = jd - Z55 A = Z56 if Z >= 2299161:57 alpha = int((Z - 1867216.26)/36254.25)58 A = Z + 1 + alpha - int(alpha//4)59 B = A + 152460 C = int((B - 122.1)/365.25)61 D = int(365.25 * C)62 E = int((B - D)/30.6001)63 day = B - D - int(30.6001 * E) + F64 if E < 13.5:65 month = int(E - 1)66 else:67 month = int(E - 13)68 if month > 2.5:69 year = int(C - 4716)70 else:71 year = int(C - 4715)72 hr, min, sec = DecodeDay(day)73 return month, day, year, hr, min, sec74def DayOfYear(month, day, year):75 if IsLeapYear(year):76 n = int((275*month)//9 - ((month + 9)//12) + int(day) - 30)77 else:78 n = int((275*month)//9 - 2*((month + 9)//12) + int(day) - 30)79 if n < 1 or n > 366: raise "Internal error"80 return n81def DayOfWeek(month, day, year):82 julian = int(JulianAstro(month, int(day), year) + 1.5)83 return julian % 784def IsLeapYear(year):85 if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):86 return 187 else:88 return 089def IsValidDate(month, day, year):90 '''Returns true if the year is later than 1752 and the month and day91 numbers are valid.92 '''93 if month < 1 or month > 12: return 094 if int(month) != month : return 095 if year < 1753 : return 096 if day < 1.0 : return 097 if int(day) != day:98 if month == 2:99 if IsLeapYear(year):100 if day >= 30.0: return 0101 else:102 if day >= 29.0: return 0103 elif month == 9 or month == 4 or month == 6 or month == 11:104 if day >= 31.0 : return 0105 else:106 if day >= 32.0 : return 0107 else:108 if month == 2:109 if IsLeapYear(year):110 if day >= 29 : return 0111 else:112 if day >= 28 : return 0113 elif month == 9 or month == 4 or month == 6 or month == 11:114 if day >= 30 : return 0115 else:116 if day >= 31 : return 0117 return 1118def JulianAstro(month, day, year):119 "Note that day can be either an integer or a float."120 if month < 3:121 year = year - 1122 month = month + 12123 julian = int(365.25*year) + int(30.6001*(month+1)) + day + 1720994.5124 tmp = year + month / 100.0 + day / 10000.0125 if tmp >= 1582.1015:126 A = year // 100127 B = 2 - A + A//4128 julian = julian + B129 return julian * 1.0130def Julian(month, day, year):131 return int(JulianAstro(month, day, year) + 0.55)132def Julian1(date_string):133 ds = date_string134 year, month, day = int(ds[0:4]), int(ds[4:6]), int(ds[6:8])135 return int(JulianAstro(month, day, year) + 0.55)136def SelfTests():137 class TestError(Exception): pass138 if Julian(12, 31, 1989) != 2447892 : raise TestError139 if Julian(1, 1, 1990) != 2447893 : raise TestError140 if Julian(7, 4, 1776) != 2369916 : raise TestError141 if Julian(2, 29, 2000) != 2451604 : raise TestError142 if JulianAstro(1, 27.5, 333) != 1842713.0 : raise TestError143 if JulianAstro(10, 4.81, 1957) != 2436116.31: raise TestError144 if DayOfWeek(11, 13, 1949) != 0 : raise TestError145 if DayOfWeek( 5, 30, 1998) != 6 : raise TestError146 if DayOfWeek( 6, 30, 1954) != 3 : raise TestError147 if DayOfYear(11, 14, 1978) != 318 : raise TestError148 if DayOfYear( 4, 22, 1980) != 113 : raise TestError149 month, day, year, hr, min, sec = JulianToDate(2436116.31)150 if month != 10 : raise TestError151 if year != 1957 : raise TestError152 if abs(day - 4.81) > .00001 : raise TestError153 month, day, year, hr, min, sec = JulianToDate(1842713.0)154 if month != 1 : raise TestError155 if year != 333 : raise TestError156 if abs(day - 27.5) > .00001 : raise TestError157 month, day, year, hr, min, sec = JulianToDate(1507900.13)158 if month != 5 : raise TestError159 if year != -584 : raise TestError160 if abs(day - 28.63) > .00001 : raise TestError161 if NumDaysInMonth( 1, 1999) != 31 : raise TestError162 if NumDaysInMonth( 2, 1999) != 28 : raise TestError163 if NumDaysInMonth( 3, 1999) != 31 : raise TestError164 if NumDaysInMonth( 4, 1999) != 30 : raise TestError165 if NumDaysInMonth( 5, 1999) != 31 : raise TestError166 if NumDaysInMonth( 6, 1999) != 30 : raise TestError167 if NumDaysInMonth( 7, 1999) != 31 : raise TestError168 if NumDaysInMonth( 8, 1999) != 31 : raise TestError169 if NumDaysInMonth( 9, 1999) != 30 : raise TestError170 if NumDaysInMonth(10, 1999) != 31 : raise TestError171 if NumDaysInMonth(11, 1999) != 30 : raise TestError172 if NumDaysInMonth(12, 1999) != 31 : raise TestError173 if NumDaysInMonth( 1, 2000) != 31 : raise TestError174 if NumDaysInMonth( 2, 2000) != 29 : raise TestError175 if NumDaysInMonth( 3, 2000) != 31 : raise TestError176 if NumDaysInMonth( 4, 2000) != 30 : raise TestError177 if NumDaysInMonth( 5, 2000) != 31 : raise TestError178 if NumDaysInMonth( 6, 2000) != 30 : raise TestError179 if NumDaysInMonth( 7, 2000) != 31 : raise TestError180 if NumDaysInMonth( 8, 2000) != 31 : raise TestError181 if NumDaysInMonth( 9, 2000) != 30 : raise TestError182 if NumDaysInMonth(10, 2000) != 31 : raise TestError183 if NumDaysInMonth(11, 2000) != 30 : raise TestError184 if NumDaysInMonth(12, 2000) != 31 : raise TestError185 print("Tests passed")186if __name__ == "__main__":...

Full Screen

Full Screen

common-error.spec.ts

Source:common-error.spec.ts Github

copy

Full Screen

1// External class.2import { Testing, TestingToBeMatchers } from '@angular-package/testing';3// Class.4import { CommonError } from '../lib/common-error.class';5/**6 * Initialize `Testing`.7 */8const testing = new Testing(true, true);9const toBe = new TestingToBeMatchers();10/**11 * Tests.12 */13testing.describe('[counter] CommonError', () => {14 class TestError<Id extends string> extends CommonError<Id> {15 public static isError<Id extends string>(16 value: any,17 id?: Id18 ): value is CommonError<Id> {19 return super.isError(value, id);20 }21 public static defineMessage(22 templateStringsArray: TemplateStringsArray,23 ...values: any[]24 ): string {25 return super.defineMessage(templateStringsArray, ...values);26 }27 }28 const problem = 'The value must be string type.';29 const fix = 'Provide the string type instead of number.';30 const id = 'AE: 427';31 const max = 427;32 const min = 9;33 const link = 'http://duckduckgo.com';34 const template = `{problem} {fix} {id} {max} {min} {type}`;35 const type = 'string';36 const additional = { link, max, min, type };37 let testError = new TestError(problem, fix, id, template, additional);38 beforeEach(() => testError = new TestError(problem, fix, id, template, additional));39 testing40 .describe(`Accessors`, () => {41 testing42 .it(`TestError.prototype.fix`, () => expect(testError.fix).toEqual(fix))43 .it(`TestError.prototype.id`, () => expect(testError.id).toEqual(id))44 .it(`TestError.prototype.link`, () => expect(testError.link).toEqual(link))45 .it(`TestError.prototype.message`, () =>46 expect(testError.message).toEqual(47 `${problem} ${fix} ${id} ${additional.max} ${additional.min} ${additional.type}`48 )49 )50 .it(`TestError.prototype.problem`, () =>51 expect(testError.problem).toEqual(problem)52 )53 .it(`TestError.prototype.template`, () =>54 expect(testError.template).toEqual(template)55 );56 }).describe(`Properties`, () => {57 testing.it(`TestError.template`, () => expect(TestError.template).toEqual(`Problem{id}: {problem} => Fix: {fix}`));58 }).describe(`Methods`, () => {59 testing60 .it('TestError.defineMessage`${problem}${fix}${id}${template}${additional}`',61 () => expect(TestError.defineMessage`${problem}${fix}${id}${template}${additional}`).toEqual(`${problem} ${fix} ${id} ${additional.max} ${additional.min} ${additional.type}`))62 .it('TestError.defineMessage`${problem}${fix}${id}${template}${additional}`',63 () => expect(TestError.defineMessage`${problem}${fix}${id}${template}${{ min: 1 }}`).toEqual(`${problem} ${fix} ${id} ${''} ${1} ${''}`))64 .it('TestError.defineMessage`${problem}${fix}${id}${template}`',65 () => expect(TestError.defineMessage`${problem}${fix}${id}${template}`).toEqual(`${problem} ${fix} ${id} `))66 .it('TestError.defineMessage`${problem}${fix}`',67 () => expect(TestError.defineMessage`${problem}${fix}`).toEqual(`Problem${''}: ${problem} => Fix: ${fix}`))68 .it('TestError.defineMessage`${problem}`',69 () => expect(TestError.defineMessage`${problem}`).toEqual(`Problem${''}: ${problem} => Fix: ${''}`))70 .it('TestError.defineMessage`${problem}`',71 () => expect(TestError.defineMessage`${problem}`).toEqual(`Problem${''}: ${problem} => Fix: ${''}`))72 .it('TestError.defineMessage``',73 () => expect(TestError.defineMessage``).toEqual(`Problem${''}: ${''} => Fix: ${''}`))74 .it(`TestError.isError()`, () => {75 expect(TestError.isError(testError)).toBeTrue();76 expect(TestError.isError(testError, id)).toBeTrue();77 expect(TestError.isError(null, id)).toBeFalse();78 });79 });...

Full Screen

Full Screen

errors.js

Source:errors.js Github

copy

Full Screen

1define([2 "../errors/create",3 "doh"4], function(create, doh){5 var TestError = create("TestError", function(message, foo){6 this.foo = foo;7 });8 var OtherError = create("OtherError", function(message, foo, bar){9 this.bar = bar;10 }, TestError, {11 getBar: function(){12 return this.bar;13 }14 });15 var testError = new TestError("hello", "asdf"),16 otherError = new OtherError("goodbye", "qwerty", "blah");17 doh.register("tests.errors", [18 {19 name: "TestError",20 runTest: function(t){21 t.t(testError instanceof Error, "testError should be an instance of Error");22 t.t(testError instanceof TestError, "testError should be an instance of TestError");23 t.f(testError instanceof OtherError, "testError should not be an instance of OtherError");24 t.f("getBar" in testError, "testError should not have a 'getBar' property");25 t.is("hello", testError.message, "testError's message property should be 'hello'");26 if((new Error()).stack){27 t.t(!!testError.stack, "custom error should have stack set");28 }29 }30 },31 {32 name: "OtherError",33 runTest: function(t){34 t.t(otherError instanceof Error, "otherError should be an instance of Error");35 t.t(otherError instanceof TestError, "otherError should be an instance of TestError");36 t.t(otherError instanceof OtherError, "otherError should be an instance of OtherError");37 t.t("getBar" in otherError, "otherError should have a 'getBar' property");38 t.f(otherError.hasOwnProperty("getBar"), "otherError should not have a 'getBar' own property");39 t.is("blah", otherError.getBar(), "otherError should return 'blah' from getBar()");40 t.is("goodbye", otherError.message, "otherError's message property should be 'goodbye'");41 }42 }43 ]);...

Full Screen

Full Screen

yield.py

Source:yield.py Github

copy

Full Screen

1'''2generator function3'''4def fib(n):5 a, b = 0, 16 for x in range(n):7 yield a8 a,b = b, a+b9 yield 'world'10def main():11 arr = []12 for n in fib(20):13 arr.append( n )14 TestError( arr[0]==0 )15 TestError( arr[1]==1 )16 TestError( arr[2]==1 )17 TestError( arr[3]==2 )18 TestError( arr[4]==3 )19 TestError( arr[5]==5 )20 TestError( arr[6]==8 )21 TestError( arr[7]==13 )22 TestError( arr[8]==21 )23 TestError( arr[9]==34 )...

Full Screen

Full Screen

basics.py

Source:basics.py Github

copy

Full Screen

1"""string basics"""2def main():3 TestError(len('a') == 1)4 a = 'XYZ'5 TestError( a[0] == 'X' )6 TestError( a.lower() == 'xyz' )7 b = 'abc'8 TestError( b.upper() == 'ABC' )9 TestError( ord('A') == 65 )10 TestError( chr(65) == 'A' )11 c = '%s-%s' %('xxx', 'yyy')12 TestError( c == 'xxx-yyy' )13 d = 'a b c'.split()14 TestError( d[0]=='a' )15 TestError( d[1]=='b' )16 TestError( d[2]=='c' )17 e = 'x%sx' %1...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8var wpt = require('wpt');9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14});15var wpt = require('wpt');16 if (err) {17 console.log(err);18 } else {19 console.log(data);20 }21});22var wpt = require('wpt');23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28});29var wpt = require('wpt');30 if (err) {31 console.log(err);32 } else {33 console.log(data);34 }35});36var wpt = require('wpt');37 if (err) {38 console.log(err);39 } else {40 console.log(data);41 }42});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.testError(function(err) {4 if (err) {5 console.log("Error: " + err);6 } else {7 console.log("No error");8 }9});10var wpt = require('wpt');11var wpt = new WebPageTest('www.webpagetest.org');12wpt.testError(function(err) {13 if (err) {14 console.log("Error: " + err);15 } else {16 console.log("No error");17 }18});19MIT © [Saurabh](

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.testError();3var wpt = require('wpt');4wpt.testError();5var wpt = require('wpt');6wpt.testError();7var wpt = require('wpt');8wpt.testError();9var wpt = require('wpt');10wpt.testError();11var wpt = require('wpt');12wpt.testError();13var wpt = require('wpt');14wpt.testError();15var wpt = require('wpt');16wpt.testError();17var wpt = require('wpt');18wpt.testError();19var wpt = require('wpt');20wpt.testError();21var wpt = require('wpt');22wpt.testError();23var wpt = require('wpt');24wpt.testError();

Full Screen

Using AI Code Generation

copy

Full Screen

1testError(function () {2 var a = 10;3 var b = 20;4 var c = a + b;5 console.log(c);6});7![](

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful