Skip to content

Commit ad6b2bb

Browse files
committed
add constraint plain.Coder test
1 parent a5b340e commit ad6b2bb

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

memory/constraint_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2021 The pal authors (see AUTHORS)
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package memory
16+
17+
import (
18+
"testing"
19+
20+
"github.com/go-air/pal/indexing"
21+
"github.com/go-air/pal/internal/plain"
22+
)
23+
24+
func clob(codr plain.Coder) {
25+
c := codr.(*Constraint)
26+
c.Dest = 0
27+
c.Src = 0
28+
c.Kind = 0
29+
if c.Index != nil {
30+
c.Index = c.Index.Gen()
31+
}
32+
}
33+
34+
func TestConstraint(t *testing.T) {
35+
var d = []Constraint{
36+
AddressOf(11, 32),
37+
Load(12, 33),
38+
Store(13, 34),
39+
TransferIndex(14, 34, indexing.ConstVals().FromInt64(11))}
40+
for i := range d {
41+
if err := plain.TestRoundTripClobber(&d[i], clob, true); err != nil {
42+
t.Error(err)
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)