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

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py

Issue 291173010: Mojo: Mojom: Remove support for octal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import imp 5 import imp
6 import os.path 6 import os.path
7 import sys 7 import sys
8 import unittest 8 import unittest
9 9
10 # Disable lint check for finding modules: 10 # Disable lint check for finding modules:
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 handle<wtf_is_this> foo; 426 handle<wtf_is_this> foo;
427 }; 427 };
428 """ 428 """
429 with self.assertRaisesRegexp( 429 with self.assertRaisesRegexp(
430 parser.ParseError, 430 parser.ParseError,
431 r"^my_file\.mojom:2: Error: " 431 r"^my_file\.mojom:2: Error: "
432 r"Invalid handle type 'wtf_is_this':\n" 432 r"Invalid handle type 'wtf_is_this':\n"
433 r" handle<wtf_is_this> foo;$"): 433 r" handle<wtf_is_this> foo;$"):
434 parser.Parse(source, "my_file.mojom") 434 parser.Parse(source, "my_file.mojom")
435 435
436 def testValidDefaultValues(self):
437 """Tests default values that are valid (to the parser)."""
438 source = """\
439 struct MyStruct {
440 int16 a0 = 0;
441 uint16 a1 = 0x0;
442 uint16 a2 = 0x00;
443 uint16 a3 = 0x01;
444 uint16 a4 = 0xcd;
445 int32 a5 = 12345;
446 int64 a6 = -12345;
447 int64 a7 = +12345;
448 uint32 a8 = 0x12cd3;
449 uint32 a9 = -0x12cD3;
450 uint32 a10 = +0x12CD3;
451 bool a11 = true;
452 bool a12 = false;
453 float a13 = 1.2345;
454 float a14 = -1.2345;
455 float a15 = +1.2345;
456 float a16 = 123.;
457 float a17 = .123;
458 double a18 = 1.23E10;
459 double a19 = 1.E-10;
460 double a20 = .5E+10;
461 double a21 = -1.23E10;
462 double a22 = +.123E10;
463 };
464 """
465 expected = \
466 [('MODULE',
467 '',
468 None,
469 [('STRUCT',
470 'MyStruct',
471 None,
472 [('FIELD', 'int16', 'a0', ast.Ordinal(None), ('EXPRESSION', ['0'])),
473 ('FIELD', 'uint16', 'a1', ast.Ordinal(None), ('EXPRESSION', ['0x0'])),
474 ('FIELD', 'uint16', 'a2', ast.Ordinal(None), ('EXPRESSION', ['0x00'])),
475 ('FIELD', 'uint16', 'a3', ast.Ordinal(None), ('EXPRESSION', ['0x01'])),
476 ('FIELD', 'uint16', 'a4', ast.Ordinal(None), ('EXPRESSION', ['0xcd'])),
477 ('FIELD', 'int32', 'a5', ast.Ordinal(None), ('EXPRESSION', ['12345'])),
478 ('FIELD', 'int64', 'a6', ast.Ordinal(None),
479 ('EXPRESSION', ['-', ('EXPRESSION', ['12345'])])),
480 ('FIELD', 'int64', 'a7', ast.Ordinal(None),
481 ('EXPRESSION', ['+', ('EXPRESSION', ['12345'])])),
482 ('FIELD', 'uint32', 'a8', ast.Ordinal(None), ('EXPRESSION', ['0x12cd3'])),
483 ('FIELD', 'uint32', 'a9', ast.Ordinal(None),
484 ('EXPRESSION', ['-', ('EXPRESSION', ['0x12cD3'])])),
485 ('FIELD', 'uint32', 'a10', ast.Ordinal(None),
486 ('EXPRESSION', ['+', ('EXPRESSION', ['0x12CD3'])])),
487 ('FIELD', 'bool', 'a11', ast.Ordinal(None), ('EXPRESSION', ['true'])),
488 ('FIELD', 'bool', 'a12', ast.Ordinal(None), ('EXPRESSION', ['false'])),
489 ('FIELD', 'float', 'a13', ast.Ordinal(None), ('EXPRESSION', ['1.2345'])),
490 ('FIELD', 'float', 'a14', ast.Ordinal(None),
491 ('EXPRESSION', ['-', ('EXPRESSION', ['1.2345'])])),
492 ('FIELD', 'float', 'a15', ast.Ordinal(None),
493 ('EXPRESSION', ['+', ('EXPRESSION', ['1.2345'])])),
494 ('FIELD', 'float', 'a16', ast.Ordinal(None), ('EXPRESSION', ['123.'])),
495 ('FIELD', 'float', 'a17', ast.Ordinal(None), ('EXPRESSION', ['.123'])),
496 ('FIELD', 'double', 'a18', ast.Ordinal(None), ('EXPRESSION', ['1.23E10'])),
497 ('FIELD', 'double', 'a19', ast.Ordinal(None), ('EXPRESSION', ['1.E-10'])),
498 ('FIELD', 'double', 'a20', ast.Ordinal(None), ('EXPRESSION', ['.5E+10'])),
499 ('FIELD', 'double', 'a21', ast.Ordinal(None),
500 ('EXPRESSION', ['-', ('EXPRESSION', ['1.23E10'])])),
501 ('FIELD', 'double', 'a22', ast.Ordinal(None),
502 ('EXPRESSION', ['+', ('EXPRESSION', ['.123E10'])]))])])]
503 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
504
436 505
437 if __name__ == "__main__": 506 if __name__ == "__main__":
438 unittest.main() 507 unittest.main()
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698