@@ -85,6 +85,62 @@ func TestDuplicateVariable(t *testing.T) {
85
85
)
86
86
}
87
87
88
+ func TestUnboundVarInSaveAccount (t * testing.T ) {
89
+ t .Parallel ()
90
+
91
+ input := `save $unbound_mon from $unbound_acc`
92
+
93
+ program := parser .Parse (input ).Value
94
+
95
+ diagnostics := analysis .CheckProgram (program ).Diagnostics
96
+ require .Len (t , diagnostics , 2 )
97
+
98
+ assert .Equal (t ,
99
+ []analysis.Diagnostic {
100
+ {
101
+ Kind : & analysis.UnboundVariable {Name : "unbound_mon" },
102
+ Range : parser .RangeOfIndexed (input , "$unbound_mon" , 0 ),
103
+ },
104
+ {
105
+ Kind : & analysis.UnboundVariable {Name : "unbound_acc" },
106
+ Range : parser .RangeOfIndexed (input , "$unbound_acc" , 0 ),
107
+ },
108
+ },
109
+ diagnostics ,
110
+ )
111
+ }
112
+
113
+ func TestMismatchedTypeInSave (t * testing.T ) {
114
+ t .Parallel ()
115
+
116
+ input := `vars {
117
+ string $str
118
+ number $n
119
+ }
120
+
121
+ save $str from $n
122
+ `
123
+
124
+ program := parser .Parse (input ).Value
125
+
126
+ diagnostics := analysis .CheckProgram (program ).Diagnostics
127
+ require .Len (t , diagnostics , 2 )
128
+
129
+ assert .Equal (t ,
130
+ []analysis.Diagnostic {
131
+ {
132
+ Kind : & analysis.TypeMismatch {Expected : "monetary" , Got : "string" },
133
+ Range : parser .RangeOfIndexed (input , "$str" , 1 ),
134
+ },
135
+ {
136
+ Kind : & analysis.TypeMismatch {Expected : "account" , Got : "number" },
137
+ Range : parser .RangeOfIndexed (input , "$n" , 1 ),
138
+ },
139
+ },
140
+ diagnostics ,
141
+ )
142
+ }
143
+
88
144
func TestUnboundVarInSource (t * testing.T ) {
89
145
t .Parallel ()
90
146
0 commit comments