diff options
author | Robbert Harms <robbert-harms@users.noreply.github.com> | 2018-08-31 15:00:14 +0200 |
---|---|---|
committer | Eli Bendersky <eliben@users.noreply.github.com> | 2018-08-31 06:00:14 -0700 |
commit | a915c3d09b8f15ae9b70cf03497089d5063f4f3b (patch) | |
tree | 265d6223820fbff69f43f65a98cd93c09472f25a /tests | |
parent | ccd673eaeff0c84c257b62ebddc23d4a6dfe5b38 (diff) | |
download | pycparser-a915c3d09b8f15ae9b70cf03497089d5063f4f3b.tar.gz |
Correct Parsing of Floating Point Literals, issue #253 (#277)
* Corrects the type attribute of a constant node when parsing doubles. This sets the type attribute to either 'float', 'long double' or 'double' depending on if 'f|F', 'l|L' or '' is specified at the end of the constant definition.
* Add tests for previous changes.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_c_parser.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py index 90df6c5..cbba9b6 100755 --- a/tests/test_c_parser.py +++ b/tests/test_c_parser.py @@ -1216,6 +1216,27 @@ class TestCParser_fundamentals(TestCParser_base): ['Constant', 'int', '5']], ['Constant', 'int', '6']]) + d5 = 'float d = 1.0;' + self.assertEqual(self.get_decl_init(d5), + ['Constant', 'double', '1.0']) + + d51 = 'float ld = 1.0l;' + self.assertEqual(self.get_decl_init(d51), + ['Constant', 'long double', '1.0l']) + + d52 = 'float ld = 1.0L;' + self.assertEqual(self.get_decl_init(d52), + ['Constant', 'long double', '1.0L']) + + d53 = 'float ld = 1.0f;' + self.assertEqual(self.get_decl_init(d53), + ['Constant', 'float', '1.0f']) + + d54 = 'float ld = 1.0F;' + self.assertEqual(self.get_decl_init(d54), + ['Constant', 'float', '1.0F']) + + def test_decl_named_inits(self): d1 = 'int a = {.k = 16};' self.assertEqual(self.get_decl_init(d1), |