mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 02:45:51 +00:00
other components
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
e9eab22e5c
commit
68269c43a6
250 changed files with 70871 additions and 0 deletions
117
test/hwf.cpp
Normal file
117
test/hwf.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
hwf.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
hwf repros...
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2012-08-23.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"hwf.h"
|
||||
#include"f2n.h"
|
||||
#include"rational.h"
|
||||
|
||||
static void bug_set_double() {
|
||||
hwf_manager m;
|
||||
hwf a;
|
||||
|
||||
m.set(a, 0.1);
|
||||
SASSERT(m.is_regular(a));
|
||||
|
||||
m.set(a, 1.1);
|
||||
SASSERT(m.is_regular(a));
|
||||
|
||||
m.set(a, 11.3);
|
||||
SASSERT(m.is_regular(a));
|
||||
|
||||
m.set(a, 0.0);
|
||||
SASSERT(m.is_regular(a));
|
||||
}
|
||||
|
||||
static void bug_to_rational() {
|
||||
hwf_manager m;
|
||||
hwf a;
|
||||
|
||||
unsynch_mpq_manager mq;
|
||||
scoped_mpq r(mq);
|
||||
|
||||
double ad, rd;
|
||||
|
||||
m.set(a, 0.0);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
SASSERT(ad == rd);
|
||||
|
||||
m.set(a, 1.0);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
SASSERT(ad == rd);
|
||||
|
||||
m.set(a, 1.5);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
SASSERT(ad == rd);
|
||||
|
||||
m.set(a, 0.875);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
SASSERT(ad == rd);
|
||||
|
||||
m.set(a, -1.0);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
SASSERT(ad == rd);
|
||||
|
||||
m.set(a, -1.5);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
SASSERT(ad == rd);
|
||||
|
||||
m.set(a, -0.875);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
SASSERT(ad == rd);
|
||||
|
||||
m.set(a, 0.1);
|
||||
m.to_rational(a, r);
|
||||
ad = m.to_double(a);
|
||||
rd = mq.get_double(r);
|
||||
double diff = (ad-rd);
|
||||
#ifdef _WINDOWS
|
||||
// CMW: This one depends on the rounding mode,
|
||||
// which is implicit in both hwf::set and in mpq::to_double.
|
||||
SASSERT(diff >= -DBL_EPSILON && diff <= DBL_EPSILON);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void bug_is_int() {
|
||||
unsigned raw_val[2] = { 2147483648, 1077720461 };
|
||||
double val = *(double*)(raw_val);
|
||||
std::cout << val << "\n";
|
||||
hwf_manager m;
|
||||
hwf a;
|
||||
m.set(a, val);
|
||||
SASSERT(!m.is_int(a));
|
||||
}
|
||||
|
||||
void tst_hwf() {
|
||||
bug_is_int();
|
||||
bug_set_double();
|
||||
bug_to_rational();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue