How to use expect_error method in wpt

Best JavaScript code snippet using wpt

cplusplus.py

Source:cplusplus.py Github

copy

Full Screen

1# Copyright David Abrahams 2004. 2# Copyright Daniel Wallin 2006.3# Distributed under the Boost4# Software License, Version 1.0. (See accompanying5# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)6import os7import tempfile8import litre9import re10import sys11import traceback12# Thanks to Jean Brouwers for this snippet13def _caller(up=0):14 '''Get file name, line number, function name and15 source text of the caller's caller as 4-tuple:16 (file, line, func, text).17 The optional argument 'up' allows retrieval of 18 a caller further back up into the call stack.19 Note, the source text may be None and function20 name may be '?' in the returned result. In21 Python 2.3+ the file name may be an absolute22 path.23 '''24 try: # just get a few frames'25 f = traceback.extract_stack(limit=up+2)26 if f:27 return f[0]28 except:29 pass30 # running with psyco?31 return ('', 0, '', None)32class Example:33 closed = False34 in_emph = None35 36 def __init__(self, node, section, line_offset, line_hash = '#'):37 # A list of text fragments comprising the Example. Start with a #line38 # directive39 self.section = section40 self.line_hash = line_hash41 self.node = node42 self.body = []43 self.line_offset = line_offset44 self._number_of_prefixes = 045 self.emphasized = [] # indices of text strings that have been46 # emphasized. These are generally expected to be47 # invalid C++ and will need special treatment48 def begin_emphasis(self):49 self.in_emph = len(self.body)50 def end_emphasis(self):51 self.emphasized.append( (self.in_emph, len(self.body)) )52 53 def append(self, s):54 self.append_raw(self._make_line(s))55 def prepend(self, s):56 self.prepend_raw(self._make_line(s))57 def append_raw(self, s):58 self.body.append(s)59 def prepend_raw(self, s):60 self.body.insert(0,s)61 self.emphasized = [ (x[0]+1,x[1]+1) for x in self.emphasized ]62 self._number_of_prefixes += 163 def replace(self, s1, s2):64 self.body = [x.replace(s1,s2) for x in self.body]65 66 def sub(self, pattern, repl, count = 1, flags = re.MULTILINE):67 pat = re.compile(pattern, flags)68 for i,txt in enumerate(self.body):69 if count > 0:70 x, subs = pat.subn(repl, txt, count)71 self.body[i] = x72 count -= subs73 74 def wrap(self, s1, s2):75 self.append_raw(self._make_line(s2))76 self.prepend_raw(self._make_line(s1, offset = -s1.count('\n')))77 78 def replace_emphasis(self, s, index = 0):79 """replace the index'th emphasized text with s"""80 e = self.emphasized[index]81 self.body[e[0]:e[1]] = [s]82 del self.emphasized[index]83 elipsis = re.compile('^([ \t]*)([.][.][.][ \t]*)$', re.MULTILINE)84 85 def __str__(self):86 # Comment out any remaining emphasized sections87 b = [self.elipsis.sub(r'\1// \2', s) for s in self.body]88 emph = self.emphasized89 emph.reverse()90 for e in emph:91 b.insert(e[1], ' */')92 b.insert(e[0], '/* ')93 emph.reverse()94 # Add initial #line95 b.insert(96 self._number_of_prefixes,97 self._line_directive(self.node.line, self.node.source)98 )99 # Add trailing newline to avoid warnings100 b.append('\n')101 return ''.join(b)102 def __repr__(self):103 return "Example: " + repr(str(self))104 def raw(self):105 return ''.join(self.body)106 def _make_line(self, s, offset = 0):107 c = _caller(2)[1::-1]108 offset -= s.count('\n')109 return '\n%s%s\n' % (self._line_directive(offset = offset, *c), s.strip('\n'))110 def _line_directive(self, line, source, offset = None):111 if self.line_hash is None:112 return '\n'113 114 if offset is None:115 offset = self.line_offset116 117 if line is None or line <= -offset:118 line = 1119 else:120 line += offset121 if source is None:122 return '%sline %d\n' % (self.line_hash, line)123 else:124 return '%sline %d "%s"\n' % (self.line_hash, line, source)125def syscmd(126 cmd127 , expect_error = False128 , input = None129 , max_output_lines = None130 ):131 # On windows close() returns the exit code, on *nix it doesn't so132 # we need to use popen2.Popen4 instead.133 if sys.platform == 'win32':134 stdin, stdout_stderr = os.popen4(cmd)135 if input: stdin.write(input)136 stdin.close()137 138 out = stdout_stderr.read()139 status = stdout_stderr.close()140 else:141 import popen2142 process = popen2.Popen4(cmd)143 if input: process.tochild.write(input)144 out = process.fromchild.read()145 status = process.wait()146 if max_output_lines is not None:147 out = '\n'.join(out.split('\n')[:max_output_lines])148 149 if expect_error:150 status = not status151 if status:152 print153 print '========== offending command ==========='154 print cmd155 print '------------ stdout/stderr -------------'156 print expect_error and 'Error expected, but none seen' or out157 elif expect_error > 1:158 print159 print '------ Output of Expected Error --------'160 print out161 print '----------------------------------------'162 163 sys.stdout.flush()164 165 return (status,out)166def expand_vars(path):167 if os.name == 'nt':168 re_env = re.compile(r'%\w+%')169 return re_env.sub(170 lambda m: os.environ.get( m.group(0)[1:-1] )171 , path172 )173 else:174 return os.path.expandvars(path)175def remove_directory_and_contents(path):176 for root, dirs, files in os.walk(path, topdown=False):177 for name in files:178 os.remove(os.path.join(root, name))179 for name in dirs:180 os.rmdir(os.path.join(root, name))181 os.rmdir(path)182class BuildResult:183 def __init__(self, path):184 self.path = path185 def __repr__(self):186 return self.path187 def __del__(self):188 remove_directory_and_contents(self.path)189class CPlusPlusTranslator(litre.LitreTranslator):190 _exposed_attrs = ['compile', 'test', 'ignore', 'match_stdout', 'stack', 'config'191 , 'example', 'prefix', 'preprocessors', 'litre_directory',192 'litre_translator', 'includes', 'build', 'jam_prefix',193 'run_python']194 last_run_output = ''195 """Attributes that will be made available to litre code"""196 197 def __init__(self, document, config):198 litre.LitreTranslator.__init__(self, document, config)199 self.in_literal = False200 self.in_table = True201 self.preprocessors = []202 self.stack = []203 self.example = None204 self.prefix = []205 self.includes = config.includes206 self.litre_directory = os.path.split(__file__)[0]207 self.config = config208 self.litre_translator = self209 self.line_offset = 0210 self.last_source = None211 self.jam_prefix = []212 self.globals = { 'test_literals_in_tables' : False }213 for m in self._exposed_attrs:214 self.globals[m] = getattr(self, m)215 self.examples = {}216 self.current_section = None217 #218 # Stuff for use by docutils writer framework219 #220 def visit_emphasis(self, node):221 if self.in_literal:222 self.example.begin_emphasis()223 224 def depart_emphasis(self, node):225 if self.in_literal:226 self.example.end_emphasis()227 def visit_section(self, node):228 self.current_section = node['ids'][0]229 def visit_literal_block(self, node):230 if node.source is None:231 node.source = self.last_source232 self.last_source = node.source233 # create a new example234 self.example = Example(node, self.current_section, line_offset = self.line_offset, line_hash = self.config.line_hash)235 self.stack.append(self.example)236 self.in_literal = True237 def depart_literal_block(self, node):238 self.in_literal = False239 def visit_literal(self, node):240 if self.in_table and self.globals['test_literals_in_tables']:241 self.visit_literal_block(node)242 else:243 litre.LitreTranslator.visit_literal(self,node)244 245 def depart_literal(self, node):246 if self.in_table and self.globals['test_literals_in_tables']:247 self.depart_literal_block(node)248 else:249 litre.LitreTranslator.depart_literal(self,node)250 def visit_table(self,node):251 self.in_table = True252 litre.LitreTranslator.visit_table(self,node)253 254 def depart_table(self,node):255 self.in_table = False256 litre.LitreTranslator.depart_table(self,node)257 258 def visit_Text(self, node):259 if self.in_literal:260 self.example.append_raw(node.astext())261 def depart_document(self, node):262 self.write_examples()263 264 #265 # Private stuff266 #267 268 def handled(self, n = 1):269 r = self.stack[-n:]270 del self.stack[-n:]271 return r272 def _execute(self, code):273 """Override of litre._execute; sets up variable context before274 evaluating code275 """276 self.globals['example'] = self.example277 eval(code, self.globals)278 279 #280 # Stuff for use by embedded python code281 #282 def match_stdout(self, expected = None):283 if expected is None:284 expected = self.example.raw()285 self.handled()286 if not re.search(expected, self.last_run_output, re.MULTILINE):287 #if self.last_run_output.strip('\n') != expected.strip('\n'):288 print 'output failed to match example'289 print '-------- Actual Output -------------'290 print repr(self.last_run_output)291 print '-------- Expected Output -----------'292 print repr(expected)293 print '------------------------------------'294 sys.stdout.flush()295 296 def ignore(self, n = 1):297 if n == 'all':298 n = len(self.stack)299 return self.handled(n)300 def wrap(self, n, s1, s2):301 self.stack[-1].append(s2)302 self.stack[-n].prepend(s1)303 304 def compile(305 self306 , howmany = 1307 , pop = -1308 , expect_error = False309 , extension = '.o'310 , options = ['-c']311 , built_handler = lambda built_file: None312 , source_file = None313 , source_suffix = '.cpp'314 # C-style comments by default; handles C++ and YACC315 , make_comment = lambda text: '/*\n%s\n*/' % text 316 , built_file = None317 , command = None318 ):319 """320 Compile examples on the stack, whose topmost item is the last example321 seen but not yet handled so far.322 :howmany: How many of the topmost examples on the stack to compile.323 You can pass a number, or 'all' to indicate that all examples should324 be compiled.325 :pop: How many of the topmost examples to discard. By default, all of326 the examples that are compiled are discarded.327 328 :expect_error: Whether a compilation error is to be expected. Any value329 > 1 will cause the expected diagnostic's text to be dumped for330 diagnostic purposes. It's common to expect an error but see a331 completely unrelated one because of bugs in the example (you can get332 this behavior for all examples by setting show_expected_error_output333 in your config).334 :extension: The extension of the file to build (set to .exe for335 run)336 :options: Compiler flags337 :built_file: A path to use for the built file. By default, a temp338 filename is conjured up339 340 :built_handler: A function that's called with the name of the built file341 upon success.342 :source_file: The full name of the source file to write343 344 :source_suffix: If source_file is None, the suffix to use for the source file345 :make_comment: A function that transforms text into an appropriate comment.346 347 :command: A function that is passed (includes, opts, target, source), where348 opts is a string representing compiler options, target is the name of349 the file to build, and source is the name of the file into which the350 example code is written. By default, the function formats351 litre.config.compiler with its argument tuple.352 """353 # Grab one example by default354 if howmany == 'all':355 howmany = len(self.stack)356 source = '\n'.join(357 self.prefix358 + [str(x) for x in self.stack[-howmany:]]359 )360 source = reduce(lambda s, f: f(s), self.preprocessors, source)361 362 if pop:363 if pop < 0:364 pop = howmany365 del self.stack[-pop:]366 367 if len(self.stack):368 self.example = self.stack[-1]369 cpp = self._source_file_path(source_file, source_suffix)370 371 if built_file is None:372 built_file = self._output_file_path(source_file, extension)373 374 opts = ' '.join(options)375 376 includes = ' '.join(['-I%s' % d for d in self.includes])377 if not command:378 command = self.config.compiler379 if type(command) == str:380 command = lambda i, o, t, s, c = command: c % (i, o, t, s)381 382 cmd = command(includes, opts, expand_vars(built_file), expand_vars(cpp))383 if expect_error and self.config.show_expected_error_output:384 expect_error += 1385 comment_cmd = command(includes, opts, built_file, os.path.basename(cpp))386 comment = make_comment(config.comment_text(comment_cmd, expect_error))387 self._write_source(cpp, '\n'.join([comment, source]))388 #print 'wrote in', cpp389 #print 'trying command', cmd390 status, output = syscmd(cmd, expect_error)391 if status or expect_error > 1:392 print393 if expect_error and expect_error < 2:394 print 'Compilation failure expected, but none seen'395 print '------------ begin offending source ------------'396 print open(cpp).read()397 print '------------ end offending source ------------'398 399 if self.config.save_cpp:400 print 'saved in', repr(cpp)401 else:402 self._remove_source(cpp)403 sys.stdout.flush()404 else:405 print '.',406 sys.stdout.flush()407 built_handler(built_file)408 409 self._remove_source(cpp)410 411 try:412 self._unlink(built_file)413 except:414 if not expect_error:415 print 'failed to unlink', built_file416 417 return status418 def test(419 self420 , rule = 'run'421 , howmany = 1422 , pop = -1423 , expect_error = False424 , requirements = ''425 , input = ''426 ):427 # Grab one example by default428 if howmany == 'all':429 howmany = len(self.stack)430 source = '\n'.join(431 self.prefix432 + [str(x) for x in self.stack[-howmany:]]433 )434 source = reduce(lambda s, f: f(s), self.preprocessors, source)435 id = self.example.section436 if not id:437 id = 'top-level'438 if not self.examples.has_key(self.example.section):439 self.examples[id] = [(rule, source)]440 else:441 self.examples[id].append((rule, source))442 if pop:443 if pop < 0:444 pop = howmany445 del self.stack[-pop:]446 if len(self.stack):447 self.example = self.stack[-1]448 def write_examples(self):449 jam = open(os.path.join(self.config.dump_dir, 'Jamfile.v2'), 'w')450 jam.write('''451import testing ;452''')453 for id,examples in self.examples.items():454 for i in range(len(examples)):455 cpp = '%s%d.cpp' % (id, i)456 jam.write('%s %s ;\n' % (examples[i][0], cpp))457 outfile = os.path.join(self.config.dump_dir, cpp)458 print cpp,459 try:460 if open(outfile, 'r').read() == examples[i][1]:461 print ' .. skip'462 continue463 except:464 pass465 open(outfile, 'w').write(examples[i][1])466 print ' .. written'467 jam.close()468 def build(469 self470 , howmany = 1471 , pop = -1472 , source_file = 'example.cpp'473 , expect_error = False474 , target_rule = 'obj'475 , requirements = ''476 , input = ''477 , output = 'example_output'478 ):479 # Grab one example by default480 if howmany == 'all':481 howmany = len(self.stack)482 source = '\n'.join(483 self.prefix484 + [str(x) for x in self.stack[-howmany:]]485 )486 source = reduce(lambda s, f: f(s), self.preprocessors, source)487 if pop:488 if pop < 0:489 pop = howmany490 del self.stack[-pop:]491 if len(self.stack):492 self.example = self.stack[-1]493 dir = tempfile.mkdtemp()494 cpp = os.path.join(dir, source_file)495 self._write_source(cpp, source)496 self._write_jamfile(497 dir498 , target_rule = target_rule499 , requirements = requirements500 , input = input501 , output = output502 )503 cmd = 'bjam'504 if self.config.bjam_options:505 cmd += ' %s' % self.config.bjam_options506 os.chdir(dir)507 status, output = syscmd(cmd, expect_error)508 if status or expect_error > 1:509 print510 if expect_error and expect_error < 2:511 print 'Compilation failure expected, but none seen'512 print '------------ begin offending source ------------'513 print open(cpp).read()514 print '------------ begin offending Jamfile -----------'515 print open(os.path.join(dir, 'Jamroot')).read()516 print '------------ end offending Jamfile -------------'517 sys.stdout.flush()518 else:519 print '.',520 sys.stdout.flush()521 if status: return None522 else: return BuildResult(dir)523 def _write_jamfile(self, path, target_rule, requirements, input, output):524 jamfile = open(os.path.join(path, 'Jamroot'), 'w')525 contents = r"""526import modules ;527BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;528use-project /boost : $(BOOST_ROOT) ;529%s530%s %s531 : example.cpp %s532 : <include>.533 %s534 %s535 ;536 """ % (537 '\n'.join(self.jam_prefix)538 , target_rule539 , output540 , input541 , ' '.join(['<include>%s' % d for d in self.includes])542 , requirements543 )544 jamfile.write(contents)545 def run_python(546 self547 , howmany = 1548 , pop = -1549 , module_path = []550 , expect_error = False551 ):552 # Grab one example by default553 if howmany == 'all':554 howmany = len(self.stack)555 if module_path == None: module_path = []556 if isinstance(module_path, BuildResult) or type(module_path) == str:557 module_path = [module_path]558 module_path = map(lambda p: str(p), module_path)559 source = '\n'.join(560 self.prefix561 + [str(x) for x in self.stack[-howmany:]]562 )563 if pop:564 if pop < 0:565 pop = howmany566 del self.stack[-pop:]567 if len(self.stack):568 self.example = self.stack[-1]569 r = re.compile(r'^(>>>|\.\.\.) (.*)$', re.MULTILINE)570 source = r.sub(r'\2', source)571 py = self._source_file_path(source_file = None, source_suffix = 'py')572 open(py, 'w').write(source)573 old_path = os.getenv('PYTHONPATH')574 if old_path == None:575 pythonpath = ':'.join(module_path)576 old_path = ''577 else:578 pythonpath = old_path + ':%s' % ':'.join(module_path)579 os.putenv('PYTHONPATH', pythonpath)580 status, output = syscmd('python %s' % py)581 if status or expect_error > 1:582 print583 if expect_error and expect_error < 2:584 print 'Compilation failure expected, but none seen'585 print '------------ begin offending source ------------'586 print open(py).read()587 print '------------ end offending Jamfile -------------'588 sys.stdout.flush()589 else:590 print '.',591 sys.stdout.flush()592 self.last_run_output = output593 os.putenv('PYTHONPATH', old_path)594 self._unlink(py)595 def _write_source(self, filename, contents):596 open(filename,'w').write(contents)597 598 def _remove_source(self, source_path):599 os.unlink(source_path)600 def _source_file_path(self, source_file, source_suffix):601 if source_file is None:602 cpp = tempfile.mktemp(suffix=source_suffix)603 else:604 cpp = os.path.join(tempfile.gettempdir(), source_file)605 return cpp606 607 def _output_file_path(self, source_file, extension):608 return tempfile.mktemp(suffix=extension)609 def _unlink(self, file):610 file = expand_vars(file)611 if os.path.exists(file):612 os.unlink(file)613 614 def _launch(self, exe, stdin = None):615 status, output = syscmd(exe, input = stdin)616 self.last_run_output = output617 618 def run_(self, howmany = 1, stdin = None, **kw):619 new_kw = { 'options':[], 'extension':'.exe' }620 new_kw.update(kw)621 self.compile(622 howmany623 , built_handler = lambda exe: self._launch(exe, stdin = stdin)624 , **new_kw625 )626 def astext(self):627 return ""628 return '\n\n ---------------- Unhandled Fragment ------------ \n\n'.join(629 [''] # generates a leading announcement630 + [ unicode(s) for s in self.stack]631 )632class DumpTranslator(CPlusPlusTranslator):633 example_index = 1634 635 def _source_file_path(self, source_file, source_suffix):636 if source_file is None:637 source_file = 'example%s%s' % (self.example_index, source_suffix)638 self.example_index += 1639 640 cpp = os.path.join(config.dump_dir, source_file)641 return cpp642 def _output_file_path(self, source_file, extension):643 chapter = os.path.basename(config.dump_dir)644 return '%%TEMP%%\metaprogram-%s-example%s%s' \645 % ( chapter, self.example_index - 1, extension)646 def _remove_source(self, source_path):647 pass648class WorkaroundTranslator(DumpTranslator):649 """Translator used to test/dump workaround examples for vc6 and vc7. Just650 like a DumpTranslator except that we leave existing files alone.651 Warning: not sensitive to changes in .rst source!! If you change the actual652 examples in source files you will have to move the example files out of the653 way and regenerate them, then re-incorporate the workarounds.654 """655 def _write_source(self, filename, contents):656 if not os.path.exists(filename):657 DumpTranslator._write_source(self, filename, contents)658 659class Config:660 save_cpp = False661 line_hash = '#'662 show_expected_error_output = False663 max_output_lines = None664class Writer(litre.Writer):665 translator = CPlusPlusTranslator666 667 def __init__(668 self669 , config670 ):671 litre.Writer.__init__(self)672 self._config = Config()673 defaults = Config.__dict__674 # update config elements675 self._config.__dict__.update(config.__dict__)676# dict([i for i in config.__dict__.items()677# if i[0] in config.__all__]))...

Full Screen

Full Screen

requestmediakeysystemaccess.js

Source:requestmediakeysystemaccess.js Github

copy

Full Screen

1function runTest(config, qualifier) {2 var prefix = testnamePrefix(qualifier, config.keysystem) + ', requestMediaKeySystemAccess: ';3 function expect_error(keySystem, configurations, expectedError, testname) {4 var audioCapabilities = configurations.length ? configurations[0].audioCapabilities : undefined,5 videoCapabilities = configurations.length ? configurations[0].videoCapabilities : undefined,6 audiocontenttypes = audioCapabilities ? audioCapabilities.map( function(ac) { return "'" + ac.contentType + "'"; } ).join(',') : '',7 videocontenttypes = videoCapabilities ? videoCapabilities.map( function(ac) { return "'" + ac.contentType + "'"; } ).join(',') : '',8 modifiedtestname = testname.replace( '%ks', keySystem ).replace( '%audiocontenttype', audiocontenttypes ).replace( '%videocontenttype', videocontenttypes );9 promise_test(function(test) {10 return navigator.requestMediaKeySystemAccess(keySystem, configurations).then(function(a) {11 assert_unreached('Unexpected requestMediaKeySystemAccess() success.');12 }, function(e) {13 assert_equals(e.name, expectedError);14 });15 }, prefix + modifiedtestname + ' should result in ' + expectedError );16 }17 function assert_subset(actual, expected, path) {18 if (typeof expected == 'string') {19 assert_equals(actual, expected, path);20 } else {21 if (expected.hasOwnProperty('length')) {22 assert_equals(actual.length, expected.length, path + '.length');23 }24 for (property in expected) {25 assert_subset(actual[property], expected[property], path + '.' + property);26 }27 }28 }29 function expect_config(keySystem, configurations, expectedConfiguration, testname) {30 promise_test(function(test) {31 return navigator.requestMediaKeySystemAccess(keySystem, configurations).then(function(a) {32 assert_subset(a.getConfiguration(), expectedConfiguration, testname + ': ');33 });34 }, testname);35 }36 // Tests for Key System.37 expect_error('', [{}], 'InvalidAccessError', 'Empty Key System (%ks)');38 expect_error('com.example.unsupported', [{}], 'NotSupportedError', 'Unsupported Key System (%ks)');39 expect_error(config.keysystem + '.', [{}], 'NotSupportedError', 'Key System ending in "." (%ks)');40 expect_error(config.keysystem.toUpperCase(), [{}], 'NotSupportedError', 'Capitalized Key System (%ks)');41 expect_error(config.keysystem + '\u028F', [{}], 'NotSupportedError', 'Non-ASCII Key System (%ks)');42 // Parent of Clear Key not supported.43 expect_error(config.keysystem.match(/^(.*?)\./)[1], [{}], 'NotSupportedError', 'Root domain of Key System alone (%ks)');44 expect_error(config.keysystem.match(/^(.*?)\./)[0], [{}], 'NotSupportedError', 'Root domain of Key System, with dot (%ks)');45 expect_error(config.keysystem.match(/^(.*?\..*?)\./)[1], [{}], 'NotSupportedError', 'Domain of Key System along (%ks)');46 expect_error(config.keysystem.match(/^(.*?\..*?)\./)[0], [{}], 'NotSupportedError', 'Domain of Key System, with dot (%ks)');47 // Child of Clear Key not supported.48 expect_error(config.keysystem+'.foo', [{}], 'NotSupportedError', 'Child of Key System');49 // Prefixed Clear Key not supported.50 expect_error('webkit-'+config.keysystem, [{}], 'NotSupportedError', 'Prefixed Key System');51 // Incomplete names.52 expect_error(config.keysystem.substr(0,7)+config.keysystem.substr(8), [{}], 'NotSupportedError', 'Incomplete Key System name (%ks)');53 expect_error(config.keysystem.substr(0,config.keysystem.length-1), [{}], 'NotSupportedError', 'Incomplete Key System name (%ks)');54 // Spaces in key system name not supported.55 expect_error(' '+config.keysystem, [{}], 'NotSupportedError', 'Leading space in Key System name (%ks)');56 expect_error(config.keysystem.substr(0,6) + ' ' + config.keysystem.substr(6), [{}], 'NotSupportedError', 'Extra space in Key System name (%ks)');57 expect_error(config.keysystem + ' ', [{}], 'NotSupportedError', 'Trailing space in Key System name (%ks)');58 // Extra dots in key systems names not supported.59 expect_error('.' + config.keysystem, [{}], 'NotSupportedError', 'Leading dot in Key System name (%ks)');60 expect_error(config.keysystem.substr(0,6) + '.' + config.keysystem.substr(6), [{}], 'NotSupportedError', 'Trailing dot in Key System name (%ks)');61 expect_error(config.keysystem + '.', [{}], 'NotSupportedError', 'Trailing dot in Key System name (%ks)');62 // Key system name is case sensitive.63 if (config.keysystem !== config.keysystem.toUpperCase()) {64 expect_error(config.keysystem.toUpperCase(), [{}], 'NotSupportedError', 'Key System name is case sensitive (%ks)');65 }66 if (config.keysystem !== config.keysystem.toLowerCase()) {67 expect_error(config.keysystem.toLowerCase(), [{}], 'NotSupportedError', 'Key System name is case sensitive (%ks)');68 }69 // Tests for trivial configurations.70 expect_error(config.keysystem, [], 'InvalidAccessError', 'Empty supportedConfigurations');71 expect_config(config.keysystem, [{}], {}, 'Empty configuration');72 // Various combinations of supportedConfigurations.73 expect_config(config.keysystem, [{74 initDataTypes: [config.initDataType],75 audioCapabilities: [{contentType: config.audioType}],76 videoCapabilities: [{contentType: config.videoType}],77 }], {78 initDataTypes: [config.initDataType],79 audioCapabilities: [{contentType: config.audioType}],80 videoCapabilities: [{contentType: config.videoType}],81 }, 'Basic supported configuration');82 expect_config(config.keysystem, [{83 initDataTypes: ['fakeidt', config.initDataType],84 audioCapabilities: [{contentType: 'audio/fake'}, {contentType: config.audioType}],85 videoCapabilities: [{contentType: 'video/fake'}, {contentType: config.videoType}],86 }], {87 initDataTypes: [config.initDataType],88 audioCapabilities: [{contentType: config.audioType}],89 videoCapabilities: [{contentType: config.videoType}],90 }, 'Partially supported configuration');91 expect_config(config.keysystem, [{92 audioCapabilities: [{contentType: config.audioType}],93 }], {94 audioCapabilities: [{contentType: config.audioType}],95 }, 'Supported audio codec');96 expect_config(config.keysystem, [{97 audioCapabilities: [{contentType: config.audioType.replace(/^(.*?);(.*)/, "$1; $2")}],98 }], {99 audioCapabilities: [{contentType: config.audioType.replace(/^(.*?);(.*)/, "$1; $2")}],100 }, 'ContentType formatting must be preserved');101 expect_error(config.keysystem, [{102 audioCapabilities: [{contentType: 'audio/webm; codecs=fake'}],103 }], 'NotSupportedError', 'Unsupported audio codec (%audiocontenttype)');104 expect_error(config.keysystem, [{105 audioCapabilities: [{contentType: 'video/webm; codecs=fake'}],106 }], 'NotSupportedError', 'Unsupported video codec (%videocontenttype)');107 expect_error(config.keysystem, [{108 audioCapabilities: [109 {contentType: 'audio/webm; codecs=mp4a'},110 {contentType: 'audio/webm; codecs=mp4a.40.2'}111 ],112 }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');113 expect_error(config.keysystem, [{114 audioCapabilities: [{contentType: config.videoType}],115 }], 'NotSupportedError', 'Video codec specified in audio field (%audiocontenttype)');116 expect_error(config.keysystem, [{117 videoCapabilities: [{contentType: config.audioType}],118 }], 'NotSupportedError', 'Audio codec specified in video field (%videocontenttype)');119 expect_error(config.keysystem, [{120 audioCapabilities: [121 {contentType: 'audio/webm; codecs=avc1'},122 {contentType: 'audio/webm; codecs=avc1.42e01e'}123 ],124 }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');125 expect_error(config.keysystem, [{126 audioCapabilities: [127 {contentType: 'audio/mp4; codecs=vorbis'}128 ],129 }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');130 expect_config(config.keysystem, [131 {initDataTypes: ['fakeidt']},132 {initDataTypes: [config.initDataType]}133 ], {initDataTypes: [config.initDataType]}, 'Two configurations, one supported');134 expect_config(config.keysystem, [135 {initDataTypes: [config.initDataType]},136 {}137 ], {initDataTypes: [config.initDataType]}, 'Two configurations, both supported');138 // Audio MIME type does not support video codecs.139 expect_error(config.keysystem, [{140 audioCapabilities: [141 {contentType: 'audio/webm; codecs="vp8,vorbis"'},142 {contentType: 'audio/webm; codecs="vorbis, vp8"'},143 {contentType: 'audio/webm; codecs="vp8"'}144 ],145 }], 'NotSupportedError', 'Audio MIME type does not support video codecs (webm) (%audiocontenttype)');146 expect_error(config.keysystem, [{147 audioCapabilities: [148 {contentType: 'audio/mp4; codecs="avc1"'},149 {contentType: 'audio/mp4; codecs="avc1.4d401e"'},150 ],151 }], 'NotSupportedError', 'Audio MIME type does not support video codecs (mp4) (%audiocontenttype)');152 // Video MIME type does not support audio codecs.153 expect_error(config.keysystem, [{154 videoCapabilities: [155 {contentType: 'video/webm; codecs="vp8,vorbis"'},156 {contentType: 'video/webm; codecs="vorbis, vp8"'},157 {contentType: 'video/webm; codecs="vorbis"'}158 ],159 }], 'NotSupportedError', 'Video MIME type does not support audio codecs (webm) (%videocontenttype)');160 expect_error(config.keysystem, [{161 videoCapabilities: [162 {contentType: 'video/mp4; codecs="mp4a"'},163 {contentType: 'video/mp4; codecs="mp4a.40.2"'}164 ],165 }], 'NotSupportedError', 'Video MIME type does not support audio codecs (mp4) (%videocontenttype)');166 // WebM does not support AVC1/AAC.167 expect_error(config.keysystem, [{168 audioCapabilities: [169 {contentType: 'audio/webm; codecs="aac"'},170 {contentType: 'audio/webm; codecs="avc1"'},171 {contentType: 'audio/webm; codecs="vp8,aac"'}172 ],173 }], 'NotSupportedError', 'WebM audio does not support AVC1/AAC (%audiocontenttype)');174 expect_error(config.keysystem, [{175 videoCapabilities: [176 {contentType: 'video/webm; codecs="aac"'},177 {contentType: 'video/webm; codecs="avc1"'},178 {contentType: 'video/webm; codecs="vp8,aac"'}179 ],180 }], 'NotSupportedError', 'WebM video does not support AVC1/AAC (%videocontenttype)');181 // Extra space is allowed in contentType.182 expect_config(config.keysystem, [{183 videoCapabilities: [{contentType: ' ' + config.videoType}],184 }], {185 videoCapabilities: [{contentType: ' ' + config.videoType}],186 }, 'Leading space in contentType');187 expect_config(config.keysystem, [{188 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?);(.*)/, "$1 ;$2")}],189 }], {190 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?);(.*)/, "$1 ;$2")}],191 }, 'Space before ; in contentType');192 expect_config(config.keysystem, [{193 videoCapabilities: [{contentType: config.videoType + ' '}],194 }], {195 videoCapabilities: [{contentType: config.videoType + ' '}],196 }, 'Trailing space in contentType');197 expect_config(config.keysystem, [{198 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\")(.*)/, "$1 $2")}],199 }], {200 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\")(.*)/, "$1 $2")}],201 }, 'Space at start of codecs parameter');202 expect_config(config.keysystem, [{203 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\".*)\"/, "$1 \"")}],204 }], {205 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\".*)\"/, "$1 \"")}],206 }, 'Space at end of codecs parameter');207 // contentType is not case sensitive (except the codec names).208 expect_config(config.keysystem, [{209 videoCapabilities: [{contentType: 'V' + config.videoType.substr(1)}],210 }], {211 videoCapabilities: [{contentType: 'V' + config.videoType.substr(1)}],212 }, 'Video/' );213 expect_config(config.keysystem, [{214 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?)c(odecs.*)/, "$1C$2")}],215 }], {216 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?)c(odecs.*)/, "$1C$2")}],217 }, 'Codecs=');218 var t = config.videoType.match(/(.*?)(;.*)/);219 expect_config(config.keysystem, [{220 videoCapabilities: [{contentType: t[1].toUpperCase() + t[2]}],221 }], {222 videoCapabilities: [{contentType: t[1].toUpperCase() + t[2]}],223 }, 'Upper case MIME type');224 t = config.videoType.match(/(.*?)codecs(.*)/);225 expect_config(config.keysystem, [{226 videoCapabilities: [{contentType: t[1] + 'CODECS' + t[2]}],227 }], {228 videoCapabilities: [{contentType: t[1] + 'CODECS' + t[2]}],229 }, 'CODECS=');230 // Unrecognized attributes are not allowed.231 expect_error(config.keysystem, [{232 videoCapabilities: [{contentType: 'video/webm; foo="bar"'}],233 }], 'NotSupportedError', 'Unrecognized foo with webm (%videocontenttype)');234 expect_error(config.keysystem, [{235 videoCapabilities: [{contentType: 'video/mp4; foo="bar"'}],236 }], 'NotSupportedError', 'Unrecognized foo with mp4 (%videocontenttype)');237 expect_error(config.keysystem, [{238 videoCapabilities: [{contentType: config.videoType + '; foo="bar"'}],239 }], 'NotSupportedError', 'Unrecognized foo with codecs (%videocontenttype)');240 // Invalid contentTypes.241 expect_error(config.keysystem, [{242 videoCapabilities: [{contentType: 'fake'}],243 }], 'NotSupportedError', 'contentType: %videocontenttype');244 expect_error(config.keysystem, [{245 audioCapabilities: [{contentType: 'audio/fake'}],246 }], 'NotSupportedError', 'contentType: %audiocontenttype');247 expect_error(config.keysystem, [{248 videoCapabilities: [{contentType: 'video/fake'}],249 }], 'NotSupportedError', 'contentType: %videocontenttype');250 // The actual codec names are case sensitive.251 t = config.videoType.match( /(.*?codecs=\")(.*?\")(.*)/ );252 if (t[2] !== t[2].toUpperCase()) {253 expect_error(config.keysystem, [{254 videoCapabilities: [{contentType: t[1] + t[2].toUpperCase() + t[3] }],255 }], 'NotSupportedError', 'contentType: %videocontenttype');256 }257 if (t[2] !== t[2].toLowerCase()) {258 expect_error(config.keysystem, [{259 videoCapabilities: [{contentType: t[1] + t[2].toLowerCase() + t[3] }],260 }], 'NotSupportedError', 'contentType: %videocontenttype');261 }262 // Extra comma is not allowed in codecs.263 expect_error(config.keysystem, [{264 videoCapabilities: [{contentType: t[1] + ',' + t[2] + t[3] }],265 }], 'NotSupportedError', 'contentType: %videocontenttype');...

Full Screen

Full Screen

test_check_kconfigs.py

Source:test_check_kconfigs.py Github

copy

Full Screen

...21from check_kconfigs import CONFIG_NAME_MAX_LENGTH22class ApplyLine(object):23 def apply_line(self, string):24 self.checker.process_line(string + '\n', 0)25 def expect_error(self, string, expect, cleanup=None):26 try:27 with self.assertRaises(InputError) as cm:28 self.apply_line(string)29 if expect:30 self.assertEqual(cm.exception.suggested_line, expect + '\n')31 finally:32 if cleanup:33 # cleanup of the previous failure34 self.apply_line(cleanup)35 def expt_success(self, string):36 self.apply_line(string)37class TestLineRuleChecker(unittest.TestCase, ApplyLine):38 def setUp(self):39 self.checker = LineRuleChecker('Kconfig')40 def tearDown(self):41 pass42 def test_tabulators(self):43 self.expect_error('\ttest', expect=' test')44 self.expect_error('\t test', expect=' test')45 self.expect_error(' \ttest', expect=' test')46 self.expect_error(' \t test', expect=' test')47 self.expt_success(' test')48 self.expt_success('test')49 def test_trailing_whitespaces(self):50 self.expect_error(' ', expect='')51 self.expect_error(' ', expect='')52 self.expect_error('test ', expect='test')53 self.expt_success('test')54 self.expt_success('')55 def test_line_length(self):56 self.expect_error('x' * 120, expect=None)57 self.expt_success('x' * 119)58 self.expt_success('')59 def test_backslashes(self):60 self.expect_error('test \\', expect=None)61class TestSourceChecker(unittest.TestCase, ApplyLine):62 def setUp(self):63 self.checker = SourceChecker('Kconfig')64 def tearDown(self):65 pass66 def test_source_file_name(self):67 self.expect_error('source "notKconfig.test"', expect='source "Kconfig.notKconfig.test"')68 self.expect_error('source "Kconfig"', expect='source "Kconfig.Kconfig"')69 self.expt_success('source "Kconfig.in"')70 self.expt_success('source "/tmp/Kconfig.test"')71 self.expt_success('source "/tmp/Kconfig.in"')72 self.expect_error('source"Kconfig.in"', expect='source "Kconfig.in"')73 self.expt_success('source "/tmp/Kconfig.in" # comment')74class TestIndentAndNameChecker(unittest.TestCase, ApplyLine):75 def setUp(self):76 self.checker = IndentAndNameChecker('Kconfig')77 self.checker.min_prefix_length = 478 def tearDown(self):79 self.checker.__exit__('Kconfig', None, None)80class TestIndent(TestIndentAndNameChecker):81 def setUp(self):82 super(TestIndent, self).setUp()83 self.checker.min_prefix_length = 0 # prefixes are ignored in this test case84 def test_indent_characters(self):85 self.expt_success('menu "test"')86 self.expect_error(' test', expect=' test')87 self.expect_error(' test', expect=' test')88 self.expect_error(' test', expect=' test')89 self.expect_error(' test', expect=' test')90 self.expt_success(' test')91 self.expt_success(' test2')92 self.expt_success(' config')93 self.expect_error(' default', expect=' default')94 self.expt_success(' help')95 self.expect_error(' text', expect=' text')96 self.expt_success(' help text')97 self.expt_success(' menu')98 self.expt_success(' endmenu')99 self.expect_error(' choice', expect=' choice', cleanup=' endchoice')100 self.expect_error(' choice', expect=' choice', cleanup=' endchoice')101 self.expt_success(' choice')102 self.expt_success(' endchoice')103 self.expt_success(' config')104 self.expt_success('endmenu')105 def test_help_content(self):106 self.expt_success('menu "test"')107 self.expt_success(' config')108 self.expt_success(' help')109 self.expt_success(' description')110 self.expt_success(' config keyword in the help')111 self.expt_success(' menu keyword in the help')112 self.expt_success(' menuconfig keyword in the help')113 self.expt_success(' endmenu keyword in the help')114 self.expt_success(' endmenu keyword in the help')115 self.expt_success('') # newline in help116 self.expt_success(' endmenu keyword in the help')117 self.expect_error(' menu "real menu with wrong indent"',118 expect=' menu "real menu with wrong indent"', cleanup=' endmenu')119 self.expt_success('endmenu')120 def test_mainmenu(self):121 self.expt_success('mainmenu "test"')122 self.expect_error('test', expect=' test')123 self.expt_success(' not_a_keyword')124 self.expt_success(' config')125 self.expt_success(' menuconfig')126 self.expect_error('test', expect=' test')127 self.expect_error(' test', expect=' test')128 self.expt_success(' menu')129 self.expt_success(' endmenu')130 def test_ifendif(self):131 self.expt_success('menu "test"')132 self.expt_success(' config')133 self.expt_success(' help')134 self.expect_error(' if', expect=' if', cleanup=' endif')135 self.expt_success(' if')136 self.expect_error(' config', expect=' config')137 self.expt_success(' config')138 self.expt_success(' help')139 self.expt_success(' endif')140 self.expt_success(' config')141 self.expt_success('endmenu')142 def test_config_without_menu(self):143 self.expt_success('menuconfig')144 self.expt_success(' help')145 self.expt_success(' text')146 self.expt_success('')147 self.expt_success(' text')148 self.expt_success('config')149 self.expt_success(' help')150 def test_source_after_config(self):151 self.expt_success('menuconfig')152 self.expt_success(' help')153 self.expt_success(' text')154 self.expect_error(' source', expect='source')155 self.expt_success('source "Kconfig.in"')156 def test_comment_after_config(self):157 self.expt_success('menuconfig')158 self.expt_success(' # comment')159 self.expt_success(' help')160 self.expt_success(' text')161 self.expect_error('# comment', expect=' # comment')162 self.expt_success(' # second not realcomment"')163class TestName(TestIndentAndNameChecker):164 def setUp(self):165 super(TestName, self).setUp()166 self.checker.min_prefix_length = 0 # prefixes are ignored in this test case167 def test_name_length(self):168 max_length = CONFIG_NAME_MAX_LENGTH169 too_long = max_length + 1170 self.expt_success('menu "test"')171 self.expt_success(' config ABC')172 self.expt_success(' config ' + ('X' * max_length))173 self.expect_error(' config ' + ('X' * too_long), expect=None)174 self.expt_success(' menuconfig ' + ('X' * max_length))175 self.expect_error(' menuconfig ' + ('X' * too_long), expect=None)176 self.expt_success(' choice ' + ('X' * max_length))177 self.expect_error(' choice ' + ('X' * too_long), expect=None)178 self.expt_success('endmenu')179class TestPrefix(TestIndentAndNameChecker):180 def test_prefix_len(self):181 self.expt_success('menu "test"')182 self.expt_success(' config ABC_1')183 self.expt_success(' config ABC_2')184 self.expt_success(' config ABC_DEBUG')185 self.expt_success(' config ABC_ANOTHER')186 self.expt_success('endmenu')187 self.expt_success('menu "test2"')188 self.expt_success(' config A')189 self.expt_success(' config B')190 self.expect_error('endmenu', expect=None)191 def test_choices(self):192 self.expt_success('menu "test"')193 self.expt_success(' choice ASSERTION_LEVEL')194 self.expt_success(' config ASSERTION_DEBUG')195 self.expt_success(' config ASSERTION_RELEASE')196 self.expt_success(' menuconfig ASSERTION_XY')197 self.expt_success(' endchoice')198 self.expt_success(' choice DEBUG')199 self.expt_success(' config DE_1')200 self.expt_success(' config DE_2')201 self.expect_error(' endchoice', expect=None)202 self.expect_error('endmenu', expect=None)203 def test_nested_menu(self):204 self.expt_success('menu "test"')205 self.expt_success(' config DOESNT_MATTER')206 self.expt_success(' menu "inner menu"')207 self.expt_success(' config MENUOP_1')208 self.expt_success(' config MENUOP_2')209 self.expt_success(' config MENUOP_3')210 self.expt_success(' endmenu')211 self.expt_success('endmenu')212 def test_nested_ifendif(self):213 self.expt_success('menu "test"')214 self.expt_success(' config MENUOP_1')215 self.expt_success(' if MENUOP_1')216 self.expt_success(' config MENUOP_2')...

Full Screen

Full Screen

test_compile.py

Source:test_compile.py Github

copy

Full Screen

...48except SyntaxError:49 pass50if verbose:51 print "testing bad float literals"52def expect_error(s):53 try:54 eval(s)55 raise TestFailed("%r accepted" % s)56 except SyntaxError:57 pass58expect_error("2e")59expect_error("2.0e+")60expect_error("1e-")61expect_error("3-4e/21")62if verbose:63 print "testing literals with leading zeroes"64def expect_same(test_source, expected):65 got = eval(test_source)66 if got != expected:67 raise TestFailed("eval(%r) gave %r, but expected %r" %68 (test_source, got, expected))69expect_error("077787")70expect_error("0xj")71expect_error("0x.")72expect_error("0e")73expect_same("0777", 511)74expect_same("0777L", 511)75expect_same("000777", 511)76expect_same("0xff", 255)77expect_same("0xffL", 255)78expect_same("0XfF", 255)79expect_same("0777.", 777)80expect_same("0777.0", 777)81expect_same("000000000000000000000000000000000000000000000000000777e0", 777)82expect_same("0777e1", 7770)83expect_same("0e0", 0)84expect_same("0000E-012", 0)85expect_same("09.5", 9.5)86expect_same("0777j", 777j)87expect_same("00j", 0j)88expect_same("00.0", 0)89expect_same("0e3", 0)90expect_same("090000000000000.", 90000000000000.)91expect_same("090000000000000.0000000000000000000000", 90000000000000.)92expect_same("090000000000000e0", 90000000000000.)93expect_same("090000000000000e-0", 90000000000000.)94expect_same("090000000000000j", 90000000000000j)95expect_error("090000000000000") # plain octal literal w/ decimal digit96expect_error("080000000000000") # plain octal literal w/ decimal digit97expect_error("000000000000009") # plain octal literal w/ decimal digit98expect_error("000000000000008") # plain octal literal w/ decimal digit99expect_same("000000000000007", 7)100expect_same("000000000000008.", 8.)101expect_same("000000000000009.", 9.)102# Verify treatment of unary minus on negative numbers SF bug #660455103expect_same("0xffffffff", -1)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3 videoParams: {4 }5};6var wpt = new WebPageTest('www.webpagetest.org', options.key);7 if (err) return console.error(err);8 console.log('Test status:', data.statusText);9 wpt.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('SpeedIndex:', data.data.average.firstView.SpeedIndex);12 if (err) return console.error(err);13 console.log('Test status:', data.statusText);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log('SpeedIndex:', data.data.average.firstView.SpeedIndex);17 });18 });19 });20});21var wpt = require('webpagetest');22var options = {23 videoParams: {24 }25};26var wpt = new WebPageTest('www.webpagetest.org', options.key);

Full Screen

Using AI Code Generation

copy

Full Screen

1var harness = require('./harness.js');2var assert = require('assert');3var test = harness.test;4var expect_error = harness.expect_error;5var test1 = function() {6 var a = 1;7 var b = 2;8 assert.equal(a, b);9};10var test2 = function() {11 var a = 1;12 var b = 2;13 assert.equal(a, b);14};15var test3 = function() {16 var a = 1;17 var b = 2;18 assert.equal(a, b);19};20test(test1, 'Test 1');21test(test2, 'Test 2');22expect_error(test3, 'Test 3');23var assert = require('assert');24var harness = {};25harness.test = function(test, name) {26 console.log('Running test ' + name);27 test();28};29harness.expect_error = function(test, name) {30 console.log('Running test ' + name);31 try {32 test();33 } catch (e) {34 console.log(e.message);35 }36};37module.exports = harness;38 at test1 (/Users/ashish/Downloads/test.js:10:12)39 at Object.<anonymous> (/Users/ashish/Downloads/test.js:28:1)40 at Module._compile (module.js:425:26)41 at Object.Module._extensions..js (module.js:432:10)42 at Module.load (module.js:356:32)43 at Function.Module._load (module.js:312:12)44 at Function.Module.runMain (module.js:497:10)45 at startup (node.js:119:16)46 at test2 (/Users/ashish/Downloads/test.js:15:12)47 at Object.<anonymous> (/Users/ashish/Downloads/test.js:28:1)48 at Module._compile (module.js:425:26)49 at Object.Module._extensions..js (module.js:432:10)50 at Module.load (module.js:356:32)51 at Function.Module._load (module.js:312:12)

Full Screen

Using AI Code Generation

copy

Full Screen

1function expect_error() {2 if (typeof expect_error !== 'undefined') {3 expect_error();4 }5}6function test() {7 expect_error();8}9test();10 > This is a bug in the test, not in Firefox. The test is using expect_error()

Full Screen

Using AI Code Generation

copy

Full Screen

1function expect_error(e) { 2 if (e instanceof Error) {3 return true;4 }5 return false;6}7function test() {8 return 1;9}10test();11function expect_error(e) { 12 if (e instanceof Error) {13 return true;14 }15 return false;16}17function test() {18 return 1;19}20test();21function expect_error(e) { 22 if (e instanceof Error) {23 return true;24 }25 return false;26}27function test() {28 return 1;29}30test();31function expect_error(e) { 32 if (e instanceof Error) {33 return true;34 }35 return false;36}37function test() {38 return 1;39}40test();41function expect_error(e) { 42 if (e instanceof Error) {43 return true;44 }45 return false;46}47function test() {48 return 1;49}50test();51function expect_error(e) { 52 if (e instanceof Error) {53 return true;54 }55 return false;56}57function test() {58 return 1;59}60test();61function expect_error(e) { 62 if (e instanceof Error) {63 return true;64 }65 return false;66}67function test() {68 return 1;69}70test();71function expect_error(e) { 72 if (e instanceof Error) {73 return true;74 }75 return false;76}77function test() {78 return 1;79}80test();81function expect_error(e) { 82 if (e instanceof Error) {83 return true;84 }85 return false;86}87function test() {88 return 1;89}90test();

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