Fix: revert optimizations
This commit is contained in:
@@ -3,7 +3,7 @@ use cagire::forth::ResolvedValue;
|
||||
|
||||
#[test]
|
||||
fn rand_in_range() {
|
||||
let mut f = forth_seeded(12345);
|
||||
let f = forth_seeded(12345);
|
||||
f.evaluate("0 10 rand", &default_ctx()).unwrap();
|
||||
let val = stack_float(&f);
|
||||
assert!(val >= 0.0 && val < 10.0, "rand {} not in [0, 10)", val);
|
||||
@@ -11,8 +11,8 @@ fn rand_in_range() {
|
||||
|
||||
#[test]
|
||||
fn rand_deterministic() {
|
||||
let mut f1 = forth_seeded(99);
|
||||
let mut f2 = forth_seeded(99);
|
||||
let f1 = forth_seeded(99);
|
||||
let f2 = forth_seeded(99);
|
||||
f1.evaluate("0 100 rand", &default_ctx()).unwrap();
|
||||
f2.evaluate("0 100 rand", &default_ctx()).unwrap();
|
||||
assert_eq!(f1.stack(), f2.stack());
|
||||
@@ -20,16 +20,16 @@ fn rand_deterministic() {
|
||||
|
||||
#[test]
|
||||
fn seed_resets() {
|
||||
let mut f1 = forth_seeded(1);
|
||||
let f1 = forth_seeded(1);
|
||||
f1.evaluate("42 seed 0 100 rand", &default_ctx()).unwrap();
|
||||
let mut f2 = forth_seeded(999);
|
||||
let f2 = forth_seeded(999);
|
||||
f2.evaluate("42 seed 0 100 rand", &default_ctx()).unwrap();
|
||||
assert_eq!(f1.stack(), f2.stack());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coin_binary() {
|
||||
let mut f = forth_seeded(42);
|
||||
let f = forth_seeded(42);
|
||||
f.evaluate("coin", &default_ctx()).unwrap();
|
||||
let val = stack_int(&f);
|
||||
assert!(val == 0 || val == 1);
|
||||
@@ -51,7 +51,7 @@ fn chance_one() {
|
||||
|
||||
#[test]
|
||||
fn choose_from_list() {
|
||||
let mut f = forth_seeded(42);
|
||||
let f = forth_seeded(42);
|
||||
f.evaluate("10 20 30 3 choose", &default_ctx()).unwrap();
|
||||
let val = stack_int(&f);
|
||||
assert!(val == 10 || val == 20 || val == 30);
|
||||
@@ -109,7 +109,7 @@ fn mtof_ftom_roundtrip() {
|
||||
|
||||
#[test]
|
||||
fn exprand_in_range() {
|
||||
let mut f = forth_seeded(12345);
|
||||
let f = forth_seeded(12345);
|
||||
f.evaluate("1.0 100.0 exprand", &default_ctx()).unwrap();
|
||||
let val = stack_float(&f);
|
||||
assert!(val >= 1.0 && val <= 100.0, "exprand {} not in [1, 100]", val);
|
||||
@@ -117,8 +117,8 @@ fn exprand_in_range() {
|
||||
|
||||
#[test]
|
||||
fn exprand_deterministic() {
|
||||
let mut f1 = forth_seeded(99);
|
||||
let mut f2 = forth_seeded(99);
|
||||
let f1 = forth_seeded(99);
|
||||
let f2 = forth_seeded(99);
|
||||
f1.evaluate("1.0 100.0 exprand", &default_ctx()).unwrap();
|
||||
f2.evaluate("1.0 100.0 exprand", &default_ctx()).unwrap();
|
||||
assert_eq!(f1.stack(), f2.stack());
|
||||
@@ -126,8 +126,8 @@ fn exprand_deterministic() {
|
||||
|
||||
#[test]
|
||||
fn exprand_swapped_args() {
|
||||
let mut f1 = forth_seeded(42);
|
||||
let mut f2 = forth_seeded(42);
|
||||
let f1 = forth_seeded(42);
|
||||
let f2 = forth_seeded(42);
|
||||
f1.evaluate("1.0 100.0 exprand", &default_ctx()).unwrap();
|
||||
f2.evaluate("100.0 1.0 exprand", &default_ctx()).unwrap();
|
||||
assert_eq!(f1.stack(), f2.stack());
|
||||
@@ -142,7 +142,7 @@ fn exprand_requires_positive() {
|
||||
|
||||
#[test]
|
||||
fn logrand_in_range() {
|
||||
let mut f = forth_seeded(12345);
|
||||
let f = forth_seeded(12345);
|
||||
f.evaluate("1.0 100.0 logrand", &default_ctx()).unwrap();
|
||||
let val = stack_float(&f);
|
||||
assert!(val >= 1.0 && val <= 100.0, "logrand {} not in [1, 100]", val);
|
||||
@@ -150,8 +150,8 @@ fn logrand_in_range() {
|
||||
|
||||
#[test]
|
||||
fn logrand_deterministic() {
|
||||
let mut f1 = forth_seeded(99);
|
||||
let mut f2 = forth_seeded(99);
|
||||
let f1 = forth_seeded(99);
|
||||
let f2 = forth_seeded(99);
|
||||
f1.evaluate("1.0 100.0 logrand", &default_ctx()).unwrap();
|
||||
f2.evaluate("1.0 100.0 logrand", &default_ctx()).unwrap();
|
||||
assert_eq!(f1.stack(), f2.stack());
|
||||
@@ -159,8 +159,8 @@ fn logrand_deterministic() {
|
||||
|
||||
#[test]
|
||||
fn logrand_swapped_args() {
|
||||
let mut f1 = forth_seeded(42);
|
||||
let mut f2 = forth_seeded(42);
|
||||
let f1 = forth_seeded(42);
|
||||
let f2 = forth_seeded(42);
|
||||
f1.evaluate("1.0 100.0 logrand", &default_ctx()).unwrap();
|
||||
f2.evaluate("100.0 1.0 logrand", &default_ctx()).unwrap();
|
||||
assert_eq!(f1.stack(), f2.stack());
|
||||
@@ -214,7 +214,7 @@ fn bounce_underflow() {
|
||||
#[test]
|
||||
fn wchoose_all_weight_one_item() {
|
||||
for _ in 0..10 {
|
||||
let mut f = forth_seeded(42);
|
||||
let f = forth_seeded(42);
|
||||
f.evaluate("10 0.0 20 1.0 2 wchoose", &default_ctx())
|
||||
.unwrap();
|
||||
assert_eq!(stack_int(&f), 20);
|
||||
@@ -223,8 +223,8 @@ fn wchoose_all_weight_one_item() {
|
||||
|
||||
#[test]
|
||||
fn wchoose_deterministic() {
|
||||
let mut f1 = forth_seeded(99);
|
||||
let mut f2 = forth_seeded(99);
|
||||
let f1 = forth_seeded(99);
|
||||
let f2 = forth_seeded(99);
|
||||
f1.evaluate("60 0.6 64 0.3 67 0.1 3 wchoose", &default_ctx())
|
||||
.unwrap();
|
||||
f2.evaluate("60 0.6 64 0.3 67 0.1 3 wchoose", &default_ctx())
|
||||
@@ -249,7 +249,7 @@ fn wchoose_negative_weight() {
|
||||
|
||||
#[test]
|
||||
fn wchoose_quotation() {
|
||||
let mut f = forth_seeded(42);
|
||||
let f = forth_seeded(42);
|
||||
f.evaluate("{ 10 } 0.0 { 20 } 1.0 2 wchoose", &default_ctx())
|
||||
.unwrap();
|
||||
assert_eq!(stack_int(&f), 20);
|
||||
|
||||
Reference in New Issue
Block a user