Skip to content

Commit

Permalink
Add not (yet) supported test case involving tuples (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliix42 committed Feb 23, 2018
1 parent 85fb850 commit 9953fea
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ script:
- cd testcases/mainarg_clone/ && cargo run && cd ../../
- cargo run -- testcases/string_manipulation/string_manipulation.ohuao testcases/string_manipulation/string_manipulation.type-dump testcases/string_manipulation/src/
- cd testcases/string_manipulation/ && cargo run && cd ../../

# - cargo run -- testcases/tuple_values/tuple_values.ohuao testcases/tuple_values/tuple_values.type-dump testcases/tuple_values/src/
# - # cd testcases/tuple_values/ && cargo run && cd ../../
3 changes: 3 additions & 0 deletions src/typecasts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ fn get_argument_types(fn_name: String) -> Vec<String> {
"strings::count" => vec![String::from("String"), String::from("usize")],
"mainclone::calc" => vec![String::from("i32")],
"mainclone::double" => vec![String::from("i32")],
"tuples::append_to_string" => vec![String::from("String"), String::from("i32")],
"tuples::extend_string" => vec![String::from("String")],
"tuples::output_values" => vec![String::from("i32"), String::from("String"), String::from("(i32, String, usize)")],
_ => vec![],
}
}
Expand Down
6 changes: 6 additions & 0 deletions testcases/tuple_values/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "tuple_values"
version = "0.1.0"
authors = ["Felix Wittwer <[email protected]>"]

[dependencies]
8 changes: 8 additions & 0 deletions testcases/tuple_values/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod ohua_runtime;
mod tuples;

fn main() {
let (num, text, num2) = ohua_runtime::ohua_main(String::from("The number is zero."), 42);

println!("Number: {} (84), string: {}, number 2: {}", num, text, num2)
}
12 changes: 12 additions & 0 deletions testcases/tuple_values/src/tuples.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub fn append_to_string(input_string: String, input_number: i32) -> String {
input_string.replace("zero", input_number.to_string().as_str())
}

pub fn extend_string(intermediate: String) -> String {
intermediate + " Or is it?"
}

pub fn output_values(input_number: i32, extended_string: String) -> (i32, String, usize) {
let length = extended_string.len();
(input_number, extended_string, length)
}
9 changes: 9 additions & 0 deletions testcases/tuple_values/tuple_values.ohuac
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ns some_ns;

use sf tuples (append_to_string, extend_string, output_values);

fn main(input_number: i32, input_string: String) -> (i32, String, usize) {
let intermediate = append_to_string(input_string, input_number);
let extended = extend_string(intermediate);
output_values(input_number, extended)
}

0 comments on commit 9953fea

Please sign in to comment.