diff --git a/src/testsuite.in b/src/testsuite.in index 3c1c7689e0b3bc0a38cb814289ee6fd145d21c91..bb1d9953ec60eaf0d5beba97d364cd0ab55d6c8b 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,4 +1,4 @@ -test_true([["$Id: testsuite.in,v 1.261 2000/01/19 17:57:05 mast Exp $"]]); +test_true([["$Id: testsuite.in,v 1.262 2000/01/20 23:12:01 noring Exp $"]]); cond([[all_constants()->_verify_internals]], [[ @@ -3725,6 +3725,37 @@ test_equal(reverse(0x12345678),0x1e6a2c48) test_true(arrayp(rusage())) test_true(sizeof(rusage())>0) +// - has_index +test_false([[ has_index(({}), 0) ]]) +test_false([[ has_index(({}), "foo") ]]) +test_false([[ has_index(({ "a" }), -1) ]]) +test_false([[ has_index(({ "a" }), "a") ]]) +test_true([[ has_index(({ "a" }), 0) ]]) +test_false([[ has_index(({ "a" }), 1) ]]) +test_true([[ has_index(({ "a", "b" }), 1) ]]) +test_false([[ has_index(([ "a":"A" ]), 4711) ]]) +test_true([[ has_index(([ "a":"A" ]), "a") ]]) +test_false([[ has_index(([ "a":"A" ]), "A") ]]) +test_true([[ has_index(([ "a":"A", "b":"B", "c":"C" ]), "b") ]]) +test_false([[ has_index(([ "a":"A", "b":"B", "c":"C" ]), "B") ]]) +test_eval_error([[ has_index((class {})(), "foo") ]]) +test_true([[has_index((class{array _indices(){return({"a","b"});}})(),"b")]]) + +// - has_value +test_false([[ has_value(({}), 0) ]]) +test_false([[ has_value(({}), "foo") ]]) +test_false([[ has_value(({ "a" }), -1) ]]) +test_true([[ has_value(({ "a" }), "a") ]]) +test_false([[ has_value(({ "a" }), 0) ]]) +test_true([[ has_value(({ "a", "b" }), "b") ]]) +test_false([[ has_value(([ "a":"A" ]), 4711) ]]) +test_true([[ has_value(([ "a":"A" ]), "A") ]]) +test_false([[ has_value(([ "a":"A" ]), "a") ]]) +test_true([[ has_value(([ "a":"A", "b":"B", "c":"C" ]), "B") ]]) +test_false([[ has_value(([ "a":"A", "b":"B", "c":"C" ]), "b") ]]) +test_eval_error([[ has_value((class {})(), "foo") ]]) +test_true([[has_value((class{array _values(){return({"a","b"});}})(),"b")]]) + // - search test_eval_error(return search("foolbar","o",-10)) test_eval_error(return search("foolbar","o",2983742)) @@ -3748,6 +3779,33 @@ test_eq(search("fo-obar|gazonk"/"|","gazonk"),1) test_eq(search(([1:2,3:4,5:6,7:8]),4),3) test_true(zero_type(search(([1:2,3:4,5:6,7:8]),3))) test_eq(search(([1:2,3:4,5:6,7:8]),8),7) +test_do([[ + class C + { + mapping m; + + int `==() + { + foreach(indices(m), mixed x) + m_delete(m, x); + return 0; + } + + void create(mapping _m) + { + m = _m; + } + } + + mapping m = ([ ]); + C o = C(m); + + for(int i = 0; i < 100; i++) + m[i] = o; + + search(m, 4711); +]]) + // test large searches (find string, size, pattern) define(test_search,[[