Commit 876c637e authored by Ken Thompson's avatar Ken Thompson

added a distinguishing string to the error prints

R=r
OCL=28321
CL=28357
parent 68382ec0
......@@ -8,6 +8,7 @@ package main
const
(
// example from the spec
n1 = +5;
n2 = -5;
d1 = +3;
......@@ -29,16 +30,16 @@ main()
{
/* ideals */
if n1/d1 != q1 || n1%d1 != r1 {
panicln(n1, d1, n1/d1, n1%d1);
panicln("ideal-1", n1, d1, n1/d1, n1%d1);
}
if n2/d1 != q2 || n2%d1 != r2 {
panicln(n2, d1, n2/d1, n2%d1);
panicln("ideal-2", n2, d1, n2/d1, n2%d1);
}
if n1/d2 != q3 || n1%d2 != r3 {
panicln(n1, d2, n1/d2, n1%d2);
panicln("ideal-3", n1, d2, n1/d2, n1%d2);
}
if n2/d2 != q4 || n2%d2 != r4 {
panicln(n2, d2, n2/d2, n2%d2);
panicln("ideal-4", n2, d2, n2/d2, n2%d2);
}
/* int */
......@@ -48,16 +49,16 @@ main()
var id2 int = -3;
if in1/id1 != q1 || in1%id1 != r1 {
panicln(in1, id1, in1/id1, in1%id1);
panicln("int-1", in1, id1, in1/id1, in1%id1);
}
if in2/id1 != q2 || in2%id1 != r2 {
panicln(in2, id1, in2/id1, in2%id1);
panicln("int-2", in2, id1, in2/id1, in2%id1);
}
if in1/id2 != q3 || in1%id2 != r3 {
panicln(in1, id2, in1/id2, in1%id2);
panicln("int-3", in1, id2, in1/id2, in1%id2);
}
if in2/id2 != q4 || in2%id2 != r4 {
panicln(in2, id2, in2/id2, in2%id2);
panicln("int-4", in2, id2, in2/id2, in2%id2);
}
/* int8 */
......@@ -67,16 +68,16 @@ main()
var bd2 int8 = -3;
if bn1/bd1 != q1 || bn1%bd1 != r1 {
panicln(bn1, bd1, bn1/bd1, bn1%bd1);
panicln("int8-1", bn1, bd1, bn1/bd1, bn1%bd1);
}
if bn2/bd1 != q2 || bn2%bd1 != r2 {
panicln(bn2, bd1, bn2/bd1, bn2%bd1);
panicln("int8-2", bn2, bd1, bn2/bd1, bn2%bd1);
}
if bn1/bd2 != q3 || bn1%bd2 != r3 {
panicln(bn1, bd2, bn1/bd2, bn1%bd2);
panicln("int8-3", bn1, bd2, bn1/bd2, bn1%bd2);
}
if bn2/bd2 != q4 || bn2%bd2 != r4 {
panicln(bn2, bd2, bn2/bd2, bn2%bd2);
panicln("int8-4", bn2, bd2, bn2/bd2, bn2%bd2);
}
/* int16 */
......@@ -86,16 +87,16 @@ main()
var sd2 int16 = -3;
if sn1/sd1 != q1 || sn1%sd1 != r1 {
panicln(sn1, sd1, sn1/sd1, sn1%sd1);
panicln("int16-1", sn1, sd1, sn1/sd1, sn1%sd1);
}
if sn2/sd1 != q2 || sn2%sd1 != r2 {
panicln(sn2, sd1, sn2/sd1, sn2%sd1);
panicln("int16-2", sn2, sd1, sn2/sd1, sn2%sd1);
}
if sn1/sd2 != q3 || sn1%sd2 != r3 {
panicln(sn1, sd2, sn1/sd2, sn1%sd2);
panicln("int16-3", sn1, sd2, sn1/sd2, sn1%sd2);
}
if sn2/sd2 != q4 || sn2%sd2 != r4 {
panicln(sn2, sd2, sn2/sd2, sn2%sd2);
panicln("int16-4", sn2, sd2, sn2/sd2, sn2%sd2);
}
/* int32 */
......@@ -105,16 +106,16 @@ main()
var ld2 int32 = -3;
if ln1/ld1 != q1 || ln1%ld1 != r1 {
panicln(ln1, ld1, ln1/ld1, ln1%ld1);
panicln("int32-1", ln1, ld1, ln1/ld1, ln1%ld1);
}
if ln2/ld1 != q2 || ln2%ld1 != r2 {
panicln(ln2, ld1, ln2/ld1, ln2%ld1);
panicln("int32-2", ln2, ld1, ln2/ld1, ln2%ld1);
}
if ln1/ld2 != q3 || ln1%ld2 != r3 {
panicln(ln1, ld2, ln1/ld2, ln1%ld2);
panicln("int32-3", ln1, ld2, ln1/ld2, ln1%ld2);
}
if ln2/ld2 != q4 || ln2%ld2 != r4 {
panicln(ln2, ld2, ln2/ld2, ln2%ld2);
panicln("int32-4", ln2, ld2, ln2/ld2, ln2%ld2);
}
/* int64 */
......@@ -124,16 +125,42 @@ main()
var qd2 int64 = -3;
if qn1/qd1 != q1 || qn1%qd1 != r1 {
panicln(qn1, qd1, qn1/qd1, qn1%qd1);
panicln("int64-1", qn1, qd1, qn1/qd1, qn1%qd1);
}
if qn2/qd1 != q2 || qn2%qd1 != r2 {
panicln(qn2, qd1, qn2/qd1, qn2%qd1);
panicln("int64-2", qn2, qd1, qn2/qd1, qn2%qd1);
}
if qn1/qd2 != q3 || qn1%qd2 != r3 {
panicln(qn1, qd2, qn1/qd2, qn1%qd2);
panicln("int64-3", qn1, qd2, qn1/qd2, qn1%qd2);
}
if qn2/qd2 != q4 || qn2%qd2 != r4 {
panicln(qn2, qd2, qn2/qd2, qn2%qd2);
panicln("int64-4", qn2, qd2, qn2/qd2, qn2%qd2);
}
if n1/qd1 != q1 || n1%qd1 != r1 {
panicln("mixed int64-1", n1, qd1, n1/qd1, n1%qd1);
}
if n2/qd1 != q2 || n2%qd1 != r2 {
panicln("mixed int64-2", n2, qd1, n2/qd1, n2%qd1);
}
if n1/qd2 != q3 || n1%qd2 != r3 {
panicln("mixed int64-3", n1, qd2, n1/qd2, n1%qd2);
}
if n2/qd2 != q4 || n2%qd2 != r4 {
panicln("mixed int64-4", n2, qd2, n2/qd2, n2%qd2);
}
if qn1/d1 != q1 || qn1%d1 != r1 {
panicln("mixed int64-5", qn1, d1, qn1/d1, qn1%d1);
}
if qn2/d1 != q2 || qn2%d1 != r2 {
panicln("mixed int64-6", qn2, d1, qn2/d1, qn2%d1);
}
if qn1/d2 != q3 || qn1%d2 != r3 {
panicln("mixed int64-7", qn1, d2, qn1/d2, qn1%d2);
}
if qn2/d2 != q4 || qn2%d2 != r4 {
panicln("mixed int64-8", qn2, d2, qn2/d2, qn2%d2);
}
/* uint */
......@@ -141,7 +168,7 @@ main()
var uid1 uint = +3;
if uin1/uid1 != q1 || uin1%uid1 != r1 {
panicln(uin1, uid1, uin1/uid1, uin1%uid1);
panicln("uint", uin1, uid1, uin1/uid1, uin1%uid1);
}
/* uint8 */
......@@ -149,7 +176,7 @@ main()
var ubd1 uint8 = +3;
if ubn1/ubd1 != q1 || ubn1%ubd1 != r1 {
panicln(ubn1, ubd1, ubn1/ubd1, ubn1%ubd1);
panicln("uint8", ubn1, ubd1, ubn1/ubd1, ubn1%ubd1);
}
/* uint16 */
......@@ -157,7 +184,7 @@ main()
var usd1 uint16 = +3;
if usn1/usd1 != q1 || usn1%usd1 != r1 {
panicln(usn1, usd1, usn1/usd1, usn1%usd1);
panicln("uint16", usn1, usd1, usn1/usd1, usn1%usd1);
}
/* uint32 */
......@@ -165,7 +192,7 @@ main()
var uld1 uint32 = +3;
if uln1/uld1 != q1 || uln1%uld1 != r1 {
panicln(uln1, uld1, uln1/uld1, uln1%uld1);
panicln("uint32", uln1, uld1, uln1/uld1, uln1%uld1);
}
/* uint64 */
......@@ -173,12 +200,12 @@ main()
var uqd1 uint64 = +3;
if uqn1/uqd1 != q1 || uqn1%uqd1 != r1 {
panicln(uqn1, uqd1, uqn1/uqd1, uqn1%uqd1);
panicln("uint64", uqn1, uqd1, uqn1/uqd1, uqn1%uqd1);
}
if n1/uqd1 != q1 || n1%uqd1 != r1 {
panicln(n1, uqd1, n1/uqd1, n1%uqd1);
panicln("mixed uint64-1", n1, uqd1, n1/uqd1, n1%uqd1);
}
if uqn1/d1 != q1 || uqn1%d1 != r1 {
panicln(uqn1, d1, uqn1/d1, uqn1%d1);
panicln("mixed uint64-2", uqn1, d1, uqn1/d1, uqn1%d1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment