File: objects.tst

package info (click to toggle)
gap 4.15.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 110,212 kB
  • sloc: ansic: 97,261; xml: 48,343; cpp: 13,946; sh: 4,900; perl: 1,650; javascript: 255; makefile: 252; ruby: 9
file content (96 lines) | stat: -rw-r--r-- 2,475 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# Tests for functions defined in src/objects.c
#
#@local x, t1c, t2c, t1p, t2p
gap> START_TEST("kernel/objects.tst");

#
gap> t1c := NewType(NewFamily("MockFamily"), IsComponentObjectRep);;
gap> t2c := NewType(NewFamily("MockFamily"), IsNonAtomicComponentObjectRep);;
gap> t1p := NewType(NewFamily("MockFamily"), IsAtomicPositionalObjectRep);;
gap> t2p := NewType(NewFamily("MockFamily"), IsReadOnlyPositionalObjectRep);;
gap> IsIdenticalObj(t1c,t2c);
false
gap> IsIdenticalObj(t1p,t2p);
false

#
# SET_TYPE_OBJ
#
gap> SET_TYPE_OBJ(fail, fail);
Error, cannot change type of a boolean or fail

#
# SET_TYPE_COMOBJ
#
gap> SET_TYPE_COMOBJ(fail, fail);
Error, You can't make a component object from a boolean or fail
gap> SET_TYPE_COMOBJ([], fail);
Error, You can't make a component object from a empty plain list
gap> SET_TYPE_COMOBJ(MakeImmutable(rec()), fail);
Error, You can't make a component object from a record (plain,imm)
gap> x:=rec();;
gap> SET_TYPE_COMOBJ(x, t1c);
<object>
gap> IS_COMOBJ(x);
true
gap> IsIdenticalObj(TYPE_OBJ(x), t1c);
true
gap> SET_TYPE_COMOBJ(x, t2c);
<object>
gap> IsIdenticalObj(TYPE_OBJ(x), t2c);
true

#
# SET_TYPE_POSOBJ
#
gap> SET_TYPE_POSOBJ(fail, fail);
Error, You can't make a positional object from a boolean or fail
gap> SET_TYPE_POSOBJ(rec(), fail);
Error, You can't make a positional object from a record (plain)
gap> # TODO: the following should also fail, but for now we allow it
gap> # for compatibility with packages that use it
gap> #SET_TYPE_POSOBJ(MakeImmutable([]), fail);
gap> x:=[ 1, , 3 ];;
gap> SET_TYPE_POSOBJ(x, t1p);
<object>
gap> IS_POSOBJ(x);
true
gap> IsIdenticalObj(TYPE_OBJ(x), t1p);
true
gap> SET_TYPE_POSOBJ(x, t2p);
<object>
gap> IsIdenticalObj(TYPE_OBJ(x), t2p);
true
gap> x![1];
1
gap> x![2];
Error, PosObj Element: <PosObj>![2] must have an assigned value
gap> x![4];
Error, PosObj Element: <PosObj>![4] must have an assigned value

#
# CLONE_OBJ
#
gap> x := [];;
gap> CLONE_OBJ(x, 0);
Error, small integers cannot be cloned
gap> CLONE_OBJ(x, Z(2));
Error, finite field elements cannot be cloned
gap> CLONE_OBJ(x, true);
Error, booleans cannot be cloned
gap> CLONE_OBJ(x, x);
gap> x;
[  ]
gap> MakeImmutable(x);;
#@if IsHPCGAP
gap> CLONE_OBJ(x, x);
Error, CLONE_OBJ() cannot overwrite public objects
#@else
gap> CLONE_OBJ(x, x);
gap> # TODO: overwriting an immutable object via CLONE_OBJ should probably
gap> # not be allowed, but InstallValue relies on it...
#@fi

#
gap> STOP_TEST("kernel/objects.tst");