File: validation_test.go

package info (click to toggle)
addchain 0.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,396 kB
  • sloc: sh: 428; makefile: 10
file content (35 lines) | stat: -rw-r--r-- 542 bytes parent folder | download
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
package pass

import (
	"testing"

	"github.com/mmcloughlin/addchain/acc/ir"
)

func TestCheckDanglingInputsError(t *testing.T) {
	// Shift instruction followed by a reference to an intermediate result.
	p := &ir.Program{
		Instructions: []*ir.Instruction{
			{
				Output: ir.Index(3),
				Op: ir.Shift{
					X: ir.Index(0),
					S: 3,
				},
			},
			{
				Output: ir.Index(4),
				Op: ir.Add{
					X: ir.Index(1),
					Y: ir.Index(3),
				},
			},
		},
	}

	err := CheckDanglingInputs(p)

	if err == nil {
		t.Fatal("expected error")
	}
}