Skip to content

Commit

Permalink
Dev #83
Browse files Browse the repository at this point in the history
  • Loading branch information
vulogov committed Sep 23, 2024
1 parent 614aaff commit b6a54ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rust_dynamic"
description = "Support for dynamically-typed values in run-time"
version = "0.26.0"
version = "0.27.0"
edition = "2021"
license-file = "LICENSE"
repository = "https://github.com/vulogov/rust_dynamic"
Expand Down
2 changes: 1 addition & 1 deletion src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn string_op_string_int(op: Ops, x: String, y: i64) -> String {
fn string_op_string_float(op: Ops, x: String, y: f64) -> String {
match op {
Ops::Mul => x.repeat(y as usize),
Ops::Add => format!("{}{}", x, y),
Ops::Add => format!("{}{:.}", x, y),
_ => x,
}
}
Expand Down
10 changes: 9 additions & 1 deletion tests/math-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ mod tests {
}

#[test]
fn test_textbuffer_add() {
fn test_textbuffer_add_string() {
let mut x = Value::text_buffer("Hello".to_string());
let y = Value::from(" world").unwrap();
x = x + y;
assert_eq!(x.cast_string().unwrap(), "Hello world");
}

#[test]
fn test_textbuffer_add_float() {
let mut x = Value::text_buffer("Hello ".to_string());
let y = Value::from(3.14).unwrap();
x = x + y;
assert_eq!(x.cast_string().unwrap(), "Hello 3.14");
}
}

0 comments on commit b6a54ce

Please sign in to comment.