(t *testing.T)
| 303 | } |
| 304 | |
| 305 | func TestVM_OpcodeOperations(t *testing.T) { |
| 306 | tests := []struct { |
| 307 | name string |
| 308 | expr string |
| 309 | env map[string]any |
| 310 | want any |
| 311 | expectError string |
| 312 | }{ |
| 313 | // Arithmetic Operations |
| 314 | { |
| 315 | name: "basic addition", |
| 316 | expr: "2 + 3", |
| 317 | want: 5, |
| 318 | }, |
| 319 | { |
| 320 | name: "mixed type arithmetic", |
| 321 | expr: "2.5 + 3", |
| 322 | want: 5.5, |
| 323 | }, |
| 324 | { |
| 325 | name: "chained arithmetic", |
| 326 | expr: "1 + 2 * 3 - 4 / 2", |
| 327 | want: 5.0, |
| 328 | }, |
| 329 | { |
| 330 | name: "modulo operation", |
| 331 | expr: "5 % 2", |
| 332 | want: 1, |
| 333 | }, |
| 334 | { |
| 335 | name: "exponent operation", |
| 336 | expr: "2 ^ 3", |
| 337 | want: 8.0, |
| 338 | }, |
| 339 | { |
| 340 | name: "negation", |
| 341 | expr: "-5", |
| 342 | want: -5, |
| 343 | }, |
| 344 | |
| 345 | // String Operations |
| 346 | { |
| 347 | name: "string concatenation", |
| 348 | expr: `"hello" + " " + "world"`, |
| 349 | want: "hello world", |
| 350 | }, |
| 351 | { |
| 352 | name: "string starts with", |
| 353 | expr: `"hello world" startsWith "hello"`, |
| 354 | want: true, |
| 355 | }, |
| 356 | { |
| 357 | name: "string ends with", |
| 358 | expr: `"hello world" endsWith "world"`, |
| 359 | want: true, |
| 360 | }, |
| 361 | { |
| 362 | name: "string contains", |
nothing calls this directly
no test coverage detected
searching dependent graphs…