From 3d0a9b791175b3be4ebf6834c08d2cc3be5a1903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Thu, 23 Nov 2017 23:00:15 +0100 Subject: [PATCH] interpreter: Reduce to_sring method to base 10 The int's to_string method implementation has been reduced to base 10. --- mesonbuild/interpreterbase.py | 7 +------ test cases/common/165 int formatting/meson.build | 15 --------------- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 test cases/common/165 int formatting/meson.build diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 9bb311fbd..7ccc8b2ba 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -452,13 +452,8 @@ class InterpreterBase: elif method_name == 'to_string': if not posargs: return str(obj) - elif len(posargs) == 1 and isinstance(posargs[0], str): - f = 'd' if len(posargs[0].strip()) == 0 else posargs[0] - if re.match('^[bcdoxX]$', f) is None: - raise InvalidCode('Invalid format for int to string conversion "%s"' % f) - return str(('{:' + f + '}').format(obj)) else: - raise InterpreterException('int.to_string() must have either no arguments or exactly one string arguments that signify what format to use.') + raise InterpreterException('int.to_string() must have no arguments.') else: raise InterpreterException('Unknown method "%s" for an integer.' % method_name) diff --git a/test cases/common/165 int formatting/meson.build b/test cases/common/165 int formatting/meson.build deleted file mode 100644 index ea9923b3f..000000000 --- a/test cases/common/165 int formatting/meson.build +++ /dev/null @@ -1,15 +0,0 @@ -project('int formatting', 'c') - -values = [ - ['', '74'], - ['c', 'J'], - ['b', '1001010'], - ['d', '74'], - ['o', '112'], - ['x', '4a'], - ['X', '4A'] -] - -foreach value: values - assert(74.to_string(value[0]) == value[1], 'conversion is broken') -endforeach