Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Codegen no longer breaks on module ids that start with a number
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonChambers committed Aug 26, 2016
1 parent fde658b commit 230fc1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion openag/cli/firmware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ def run(
"try", "typedef", "typeid", "typename", "union", "unsigned", "using",
"virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
]
invalid_ids = [_id for _id in modules.keys() if _id in cpp_keywords]
invalid_ids = [
_id for _id in modules.keys() if _id in cpp_keywords or
_id[0].isdigit()
]
for _id in invalid_ids:
new_id = "_" + _id
modules[new_id] = modules[_id]
Expand Down
5 changes: 4 additions & 1 deletion tests/test_cli/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class MyModule : public Module {
res = runner.invoke(run_module, ["-p", "csv"])
assert res.exit_code == 0, repr(res.exception) or res.output

def test_run_cpp_keyword_as_module_id():
def test_run_invalid_module_ids():
runner = CliRunner()

with runner.isolated_filesystem():
Expand All @@ -321,6 +321,9 @@ def test_run_cpp_keyword_as_module_id():
json.dump({
"for": {
"type": "module"
},
"123": {
"type": "module"
}
}, f)

Expand Down

0 comments on commit 230fc1e

Please sign in to comment.