if(f2 != T) {
if(needaddr(n->left->type)) {
+ walktype(n->left, Elv);
n->left = nod(OADDR, n->left, N);
n->left->type = ptrto(n->left->left->type);
}
// arrays2d(old *any, nel int) (ary []any)
t = fixarray(n->right->type);
tl = fixarray(n->left->type);
+ if(t == T || tl == T)
+ break;
a = nodintconst(t->bound); // nel
a = nod(OCONV, a, N);
case ONEW:
// newarray(nel int, max int, width int) (ary []any)
t = fixarray(n->type);
+ if(t == T)
+ break;
a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N);
// arraysliced(old []any, lb int, hb int, width int) (ary []any)
t = fixarray(n->left->type);
+ if(t == T)
+ break;
a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N);
a->type = types[TINT];
r = list(a, r);
- t = fixarray(n->left->type);
if(t->bound >= 0) {
// static slice
a = nodintconst(t->bound); // nel
if z1.Cmp(z2) != 0 {
tester.Fatalf("multiplication not symmetric:\n\tx = %v\n\ty = %t", x, y);
}
- if !x.IsZero() && z1.Div(x).Cmp(y) != 0 {
- tester.Fatalf("multiplication/division not inverse (A):\n\tx = %v\n\ty = %t", x, y);
+ // BUG if !x.IsZero() && z1.Div(x).Cmp(y) != 0 {
+ if !x.IsZero() {
+ na := z1.Div(x);
+ if na.Cmp(y) != 0 {
+ tester.Fatalf("multiplication/division not inverse (A):\n\tx = %v\n\ty = %t", x, y);
+ }
}
- if !y.IsZero() && z1.Div(y).Cmp(x) != 0 {
- tester.Fatalf("multiplication/division not inverse (B):\n\tx = %v\n\ty = %t", x, y);
+ // BUG if !y.IsZero() && z1.Div(y).Cmp(x) != 0 {
+ if !y.IsZero() {
+ nb := z1.Div(y);
+ if nb.Cmp(x) != 0 {
+ tester.Fatalf("multiplication/division not inverse (B):\n\tx = %v\n\ty = %t", x, y);
+ }
}
return z1;
}
test_msg = "NatMulC";
const n = 100;
- p := b.Mul(c).Shl(n);
+ // BUG p := b.Mul(c).Shl(n);
+ na := b.Mul(c);
+ p := na.Shl(n);
for i := uint(0); i < n; i++ {
NAT_EQ(i, Mul(b.Shl(i), c.Shl(n-i)), p);
}
for i := uint(0); ; i++ {
d := nat_one.Shl(i);
if d.Cmp(c) < 0 {
- NAT_EQ(i, c.Add(d).Mod(c), d);
+ //BUG NAT_EQ(i, c.Add(d).Mod(c), d);
+ na := c.Add(d);
+ NAT_EQ(i, na.Mod(c), d);
} else {
- NAT_EQ(i, c.Add(d).Div(c), nat_two);
- NAT_EQ(i, c.Add(d).Mod(c), d.Sub(c));
+ //BUG NAT_EQ(i, c.Add(d).Div(c), nat_two);
+ na := c.Add(d);
+ NAT_EQ(i, na.Div(c), nat_two);
+ //BUG NAT_EQ(i, c.Add(d).Mod(c), d.Sub(c));
+ nb := c.Add(d);
+ NAT_EQ(i, nb.Mod(c), d.Sub(c));
break;
}
}
test_msg = "NatLog2A";
TEST(0, nat_one.Log2() == 0);
TEST(1, nat_two.Log2() == 1);
- TEST(2, bignum.Nat(3).Log2() == 1);
- TEST(3, bignum.Nat(4).Log2() == 2);
+ //BUG TEST(2, bignum.Nat(3).Log2() == 1);
+ na := bignum.Nat(3);
+ TEST(2, na.Log2() == 1);
+ //BUG TEST(3, bignum.Nat(4).Log2() == 2);
+ nb := bignum.Nat(4);
+ TEST(3, nb.Log2() == 2);
test_msg = "NatLog2B";
for i := uint(0); i < 100; i++ {
- TEST(i, nat_one.Shl(i).Log2() == i);
+ //BUG TEST(i, nat_one.Shl(i).Log2() == i);
+ nc := nat_one.Shl(i);
+ TEST(i, nc.Log2() == i);
}
}
test_msg = "NatPopA";
TEST(0, nat_zero.Pop() == 0);
TEST(1, nat_one.Pop() == 1);
- TEST(2, bignum.Nat(10).Pop() == 2);
- TEST(3, bignum.Nat(30).Pop() == 4);
+ //BUG TEST(2, bignum.Nat(10).Pop() == 2);
+ na := bignum.Nat(10);
+ TEST(2, na.Pop() == 2);
+ //BUG TEST(3, bignum.Nat(30).Pop() == 4);
+ nb := bignum.Nat(30);
+ TEST(3, nb.Pop() == 4);
// BUG TEST(4, bignum.Nat(0x1248f).Shl(33).Pop() == 8);
g := bignum.Nat(0x1248f);
g = g.Shl(33);