Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,57 @@
"words": [
"allocs",
"bitflags",
"builtins",
"bitpattern",
"bitwidth",
"brainfuck",
"builtins",
"centimanes",
"cfgs",
"cmps",
"combinators",
"concat",
"condvar",
"cottus",
"Cremer",
"delims",
"deque",
"desugared",
"dprint",
"dyntest",
"Eisel",
"Emax",
"Emin",
"expf",
"extrinsics",
"fizzbuzz",
"freelist",
"furiosity",
"gyges",
"hashbrown",
"hfsq",
"hihi",
"ilog",
"impls",
"indexmap",
"interner",
"interstage",
"IVLN",
"Lemire",
"libm",
"logf",
"Marsaglia",
"miri",
"msun",
"nats",
"nilary",
"nohash",
"nonoverlapping",
"nums",
"ovfl",
"parens",
"peekable",
"polyformic",
"powf",
"primality",
"primenesses",
"proto",
Expand All @@ -51,21 +65,26 @@
"rfold",
"rotr",
"rustyline",
"scalbn",
"scrutinee",
"sequentializing",
"significand",
"sixel",
"specializer",
"strs",
"structs",
"subexpressions",
"subimpls",
"subnorm",
"Subnormals",
"subpattern",
"subpatterns",
"unpark",
"vecs",
"visitee",
"whnf",
"woah"
"woah",
"yisint"
],
"dictionaries": [
"rust"
Expand Down
8 changes: 7 additions & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
"exts": ["vi"]
}]
},
"excludes": ["tests/programs/fail", "tests/programs/repl", "tests/programs/fmt", "tests/snaps"],
"excludes": [
"tests/programs/fail",
"tests/programs/repl",
"tests/programs/fmt",
"tests/snaps",
"tests/programs/floats.vi"
],
"plugins": [
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm",
"https://plugins.dprint.dev/json-0.19.3.wasm",
Expand Down
1 change: 1 addition & 0 deletions ivy/src/host/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl<'ivm> Host<'ivm> {
"f32_mul" => |a, b| new_f32(as_f32(a).mul(as_f32(b))),
"f32_div" => |a, b| new_f32(as_f32(a).div(as_f32(b))),
"f32_rem" => |a, b| new_f32(as_f32(a).rem_euclid(as_f32(b))),
"f32_sqrt" => |a, _b| new_f32(as_f32(a).sqrt()),

"f32_eq" => |a, b| new_bool(as_f32(a) == as_f32(b)),
"f32_ne" => |a, b| new_bool(as_f32(a) != as_f32(b)),
Expand Down
53 changes: 53 additions & 0 deletions tests/programs/floats.vi
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// FIX(#110): formatting is currently disabled in dprint.json to keep the comments in this file.
// Enable formatting again once #110 is fixed.
pub fn main(&io: &IO) {
let interesting_floats = [
// 1) Specials / domain errors
+0.0,
-0.0,
-42.0,
F32::inf,
F32::neg_inf,
F32::nan,
F32::from_bits(0x7FC0_0001), // quiet NaN w/ payload
// 2) Subnormals & very small positives
F32::from_bits(0x0000_0001), // smallest subnormal
F32::from_bits(0x0000_0002),
F32::from_bits(0x0040_0000),
F32::from_bits(0x007F_FFFF), // largest subnormal
F32::from_bits(0x0080_0000), // FLT_MIN (smallest normal)
// 3) Around 1.0 (cancellation-sensitive)
1.0,
F32::from_bits(0x3F7F_FFFF),
F32::from_bits(0x3F80_0001),
F32::from_bits(0x3F7F_FFFE), // cspell:disable-line
F32::from_bits(0x3F80_0002),
// 4) Nice reference values
0.5,
2.0,
2.7182817, // e (rounded in F32)
3.1415927, // π (rounded in F32)
// 5) Range extremes & powers of two
F32::from_bits(0x3080_0000), // 2^-30
F32::from_bits(0x4E80_0000), // 2^30
F32::from_bits(0x0100_0000), // FLT_MIN * 2
F32::from_bits(0x7EFF_FFFF), // FLT_MAX / 2
F32::from_bits(0x7F7F_FFFF), // FLT_MAX
1.0e-10,
1.0e10,
];

for &f in interesting_floats.iter() {
io.println("f = {f}");
io.println("ln(f) = {f.ln()}");
io.println("sqrt(f) = {f.sqrt()}");
io.println("exp(f) = {f.exp()}");
io.println("");
}

for &f1 in interesting_floats.iter() {
for &f2 in interesting_floats.iter() {
io.println("{f1 ** f2}");
}
}
}
12 changes: 8 additions & 4 deletions tests/programs/option_party.vi
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

pub fn main(&io: &IO) {
let fn print_option_n32(option: Option[N32]) {
io.println(" " ++ match option {
Some(val) { "Some({val})" }
None { "None" }
})
io.println(" {option.show()}")
}

let fn print_n32(val: N32) {
Expand Down Expand Up @@ -73,6 +70,13 @@ pub fn main(&io: &IO) {
print_bool(Some(0) is Some(x) => x > 0);
print_bool(Some(1) is Some(x) => x > 0);

io.println("take:");
let option = Some(3);
print_option_n32(option.take());
print_option_n32(option);
print_option_n32(option.take());
print_option_n32(option);

io.println("unwrap:");
print_n32(Some(42).unwrap());
print_n32(None.unwrap());
Expand Down
12 changes: 0 additions & 12 deletions tests/programs/repl/f32_to_string.vi

This file was deleted.

Loading