Skip to content

Commit

Permalink
Merge pull request #100 from srz-zumix/feature/rust_end_of_statement
Browse files Browse the repository at this point in the history
fix rust: Multiple mod on one line
  • Loading branch information
srz-zumix authored Jul 29, 2022
2 parents 73f6d70 + 45ca720 commit ac4bc1c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion samples/command/src/rust/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// This file is a "Hello, world!" in Rust language for wandbox.

mod test1;
mod test1; mod test2;

fn main()
{
println!("Hello, Wandbox!");
test1::test1();
test2::test2();
}

// Rust language references:
Expand Down
4 changes: 4 additions & 0 deletions samples/command/src/rust/src/test2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub fn test2()
{
println!("Test2");
}
2 changes: 1 addition & 1 deletion tests/test_wandbox_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_options_config(self):
head = ll[0]
# print(json.dumps(head, indent=2))
self.assertEqual(cli.has_compiler_option_raw, head['compiler-option-raw'], cli.language)
# self.assertEqual(cli.has_runtime_option_raw, head['runtime-option-raw'])
# self.assertEqual(cli.has_runtime_option_raw, head['runtime-option-raw'], cli.language)
self.assertEqual(cli.has_runtime_option_raw, cli.language != "OpenSSL", cli.language)
self.assertEqual(cli.has_option, len(head['switches']) != 0, cli.language)

Expand Down
6 changes: 3 additions & 3 deletions wandbox/__rust__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class RustRunner(Runner):

MOD_REGEX = re.compile(r'^\s*mod\s+(.*?);\s*$')
MOD_REGEX = re.compile(r'\s*mod\s+(.*?)\s*;')

def reset(self):
self.modules = []
Expand All @@ -19,8 +19,8 @@ def make_code(self, file, filepath, filename):
files = dict()
code = ''
for line in file:
m = self.MOD_REGEX.match(line)
if m:
ml = self.MOD_REGEX.finditer(line)
for m in ml:
files.update(self.mod(os.path.dirname(filepath), m.group(1)))
code += line
files[filename] = code
Expand Down

0 comments on commit ac4bc1c

Please sign in to comment.