parent
5f182dc1cc
commit
559ee3e3e1
3 changed files with 45 additions and 5 deletions
|
@ -81,10 +81,26 @@ static void tst3() {
|
|||
check(b, {1000, 2000, 0, 1, 2, 3, 100, 4, 300});
|
||||
}
|
||||
|
||||
static void tst4() {
|
||||
buffer<buffer<int>> b;
|
||||
for (unsigned j = 38; j < 40; j++) {
|
||||
for (unsigned i = 0; i < j; i++) {
|
||||
b.push_back(buffer<int>());
|
||||
for (unsigned k = 0; k < 10; k++) {
|
||||
b.back().push_back(k);
|
||||
}
|
||||
}
|
||||
lean_assert(b.size() == j);
|
||||
b.clear();
|
||||
lean_assert(b.size() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
loop<buffer<int>>(100);
|
||||
tst1();
|
||||
tst2();
|
||||
tst3();
|
||||
tst4();
|
||||
return has_violations() ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -30,11 +30,12 @@ protected:
|
|||
}
|
||||
|
||||
void expand() {
|
||||
unsigned new_capacity = m_capacity << 1;
|
||||
char * new_buffer = new char[sizeof(T) * new_capacity];
|
||||
std::memcpy(new_buffer, static_cast<void*>(m_buffer), m_pos * sizeof(T));
|
||||
free_memory();
|
||||
m_buffer = reinterpret_cast<T*>(new_buffer);
|
||||
unsigned new_capacity = m_capacity << 1;
|
||||
char * new_buffer_char = new char[sizeof(T) * new_capacity];
|
||||
T * new_buffer = reinterpret_cast<T*>(new_buffer_char);
|
||||
std::uninitialized_copy(m_buffer, m_buffer + m_pos, new_buffer);
|
||||
destroy();
|
||||
m_buffer = new_buffer;
|
||||
m_capacity = new_capacity;
|
||||
}
|
||||
|
||||
|
|
23
tests/lean/hott/crash1.hlean
Normal file
23
tests/lean/hott/crash1.hlean
Normal file
|
@ -0,0 +1,23 @@
|
|||
import types.sigma types.prod
|
||||
import algebra.binary algebra.group
|
||||
open eq eq.ops
|
||||
|
||||
namespace path_algebra
|
||||
|
||||
variable {A : Type}
|
||||
|
||||
structure distrib [class] (A : Type) extends has_mul A, has_add A :=
|
||||
(left_distrib : ∀a b c, mul a (add b c) = add (mul a b) (mul a c))
|
||||
(right_distrib : ∀a b c, mul (add a b) c = add (mul a c) (mul b c))
|
||||
|
||||
structure mul_zero_class [class] (A : Type) extends has_mul A, has_zero A :=
|
||||
(zero_mul : Πa, mul zero a = zero)
|
||||
(mul_zero : Πa, mul a zero = zero)
|
||||
|
||||
structure zero_ne_one_class [class] (A : Type) extends has_zero A, has_one A :=
|
||||
(zero_ne_one : zero ≠ one)
|
||||
|
||||
structure semiring [class] (A : Type) extends add_comm_monoid A, monoid A,
|
||||
distrib A, mul_zero_class A, zero_ne_one_class A
|
||||
|
||||
end path_algebra
|
Loading…
Reference in a new issue