How to use test_parse method in tempest

Best Python code snippet using tempest_python

e_parser.py

Source:e_parser.py Github

copy

Full Screen

...337def parse_string(string, src_name):338 """Parse a string and returns a function"""339 input_handler_handler = Input(src_name, string)340 return parse_unit(input_handler_handler)341def test_parse(string):342 """Testing success"""343 parse_string(string, "test success")344def test_parse_fail(string):345 """Testing failure"""346 try:347 parse_string(string, "test fail")348 except ParseError:349 return350 raise Exception("Parsing did not fail for: " + string)351def test_parser():352 """Testing"""353 print("parser tests")354 # ids355 test_parse("foo;")356 test_parse(" foo ;")357 test_parse(" foo;")358 # literals359 test_parse("42;")360 test_parse("42.42f;")361 test_parse("42e42f;")362 test_parse("42.4e4f;")363 test_parse('"test me!";')364 test_parse('"test me! \'lol\'";')365 test_parse("'test \\n newline';")366 test_parse("true;")367 test_parse("false;")368 test_parse_fail("invalid \\iesc")369 # arrays370 test_parse("[];")371 test_parse("[1,2];")372 test_parse("[1,e];")373 test_parse("['aa', 'bb', 4.4f];")374 test_parse("[1, \n3];")375 test_parse_fail("[,];")376 # objects377 test_parse("let a := {a:2, b:'c'};")378 test_parse_fail("a := {,}")379 # Comments380 test_parse("1; // comment")381 test_parse("[ 1//comment\n,a ];")382 test_parse_fail("1; // comment\n#1")383 # Unary and binary expressions384 test_parse("-1;")385 test_parse("-x + 2;")386 test_parse("x + -1;")387 test_parse("a + b;")388 test_parse("a + b + c;")389 test_parse("a + b - c;")390 test_parse("a + b * c + d;")391 test_parse("a or b or c;")392 test_parse("(a);")393 test_parse("(b ) ;")394 test_parse("(a + b);")395 test_parse("(a + (b + c));")396 test_parse("((a + b) + c);")397 test_parse("(a + b) * (c + d);")398 test_parse_fail("*a;")399 test_parse_fail("a*;")400 test_parse_fail("a # b;")401 test_parse_fail("a +;")402 test_parse_fail("a + b # c;")403 test_parse_fail("(a;")404 test_parse_fail("(a + b))")405 test_parse_fail("((a + b)")406 # Assignment407 test_parse("x := 1;")408 test_parse("x := -1;")409 test_parse("x := y := 1;")410 test_parse("let x := 3;")411 test_parse_fail("let")412 test_parse_fail("var")413 test_parse_fail("var x")414 test_parse_fail("var x:=")415 test_parse_fail("let +")416 test_parse_fail("let 3")417 # Call expressions418 test_parse("a();")419 test_parse("a(b);")420 test_parse("a(b,c);")421 test_parse("a(b,c+1);")422 test_parse("a(b,c+1,);")423 test_parse("x + a(b,c+1);")424 test_parse("x + a(b,c+1) + y;")425 test_parse("a(); b();")426 test_parse_fail("a(b c+1);")427 # package import428 test_parse("import( 'package/math' as math )")429 test_parse("import( 'package/math' as m )")430 test_parse_fail("import( '1' as one, '2', '3' as three )")431 # export statement432 test_parse("export(a, b)")433 test_parse("export(c)")434 test_parse_fail("export(1)")435 test_parse_fail("export('a')")436 # Inline IR437 test_parse("let s := $add_i32(1, 2);")438 test_parse("$array_push(arr, val);")439 # If statements440 test_parse("if (true) {x + 1;}")441 test_parse("if (x) {x+1;} else {y+1;}")442 # Assert statement443 test_parse("assert(x);")444 test_parse("assert(x, 'foo');")445 test_parse_fail("assert(x, 'foo', z);")446 # Function expression447 test_parse("fun () { return 0; }; ")448 test_parse("fun (x) {return x;};")449 test_parse("fun (x) { return x; };")450 test_parse("fun (x,y) { return x; };")451 test_parse("fun (x,y,) { return x; };")452 test_parse("fun (x,y) { return x+y; };")453 test_parse_fail("fun (x,y)")454 # Sequence/block expression455 test_parse("{ 1; 2; }")456 test_parse("fun (x) { print(x); print(y); };")457 test_parse("fun (x) { let y := x + 1; print(y); };")458 test_parse_fail("{ a, }")459 test_parse_fail("{ a, b }")460 test_parse_fail("fun () { a, };")461 # There is no empty statement...

Full Screen

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 tempest 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