@@ -356,3 +356,120 @@ fn expr_2021() {
356
356
;"# ] ] ,
357
357
) ;
358
358
}
359
+
360
+ #[ test]
361
+ fn minus_belongs_to_literal ( ) {
362
+ let decl = r#"
363
+ (-1) => {-1};
364
+ (- 2) => {- 2};
365
+ (- 3.0) => {- 3.0};
366
+ (@$lit:literal) => {$lit}
367
+ "# ;
368
+ let check = |args, expect| check ( Edition :: CURRENT , Edition :: CURRENT , decl, args, expect) ;
369
+ check (
370
+ "-1" ,
371
+ expect ! [ [ r#"
372
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
373
+ PUNCH - [alone] 0:[email protected] #ROOT2024
374
+ LITERAL Integer 1 0:[email protected] #ROOT2024
375
+
376
+ -1"# ] ] ,
377
+ ) ;
378
+ check (
379
+ "- 1" ,
380
+ expect ! [ [ r#"
381
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
382
+ PUNCH - [alone] 0:[email protected] #ROOT2024
383
+ LITERAL Integer 1 0:[email protected] #ROOT2024
384
+
385
+ -1"# ] ] ,
386
+ ) ;
387
+ check (
388
+ "-2" ,
389
+ expect ! [ [ r#"
390
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
391
+ PUNCH - [alone] 0:[email protected] #ROOT2024
392
+ LITERAL Integer 2 0:[email protected] #ROOT2024
393
+
394
+ -2"# ] ] ,
395
+ ) ;
396
+ check (
397
+ "- 2" ,
398
+ expect ! [ [ r#"
399
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
400
+ PUNCH - [alone] 0:[email protected] #ROOT2024
401
+ LITERAL Integer 2 0:[email protected] #ROOT2024
402
+
403
+ -2"# ] ] ,
404
+ ) ;
405
+ check (
406
+ "-3.0" ,
407
+ expect ! [ [ r#"
408
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
409
+ PUNCH - [alone] 0:[email protected] #ROOT2024
410
+ LITERAL Float 3.0 0:[email protected] #ROOT2024
411
+
412
+ -3.0"# ] ] ,
413
+ ) ;
414
+ check (
415
+ "- 3.0" ,
416
+ expect ! [ [ r#"
417
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
418
+ PUNCH - [alone] 0:[email protected] #ROOT2024
419
+ LITERAL Float 3.0 0:[email protected] #ROOT2024
420
+
421
+ -3.0"# ] ] ,
422
+ ) ;
423
+ check (
424
+ "@1" ,
425
+ expect ! [ [ r#"
426
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
427
+ LITERAL Integer 1 1:[email protected] #ROOT2024
428
+
429
+ 1"# ] ] ,
430
+ ) ;
431
+ check (
432
+ "@-1" ,
433
+ expect ! [ [ r#"
434
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
435
+ PUNCH - [alone] 1:[email protected] #ROOT2024
436
+ LITERAL Integer 1 1:[email protected] #ROOT2024
437
+
438
+ -1"# ] ] ,
439
+ ) ;
440
+ check (
441
+ "@1.0" ,
442
+ expect ! [ [ r#"
443
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
444
+ LITERAL Float 1.0 1:[email protected] #ROOT2024
445
+
446
+ 1.0"# ] ] ,
447
+ ) ;
448
+ check (
449
+ "@-1.0" ,
450
+ expect ! [ [ r#"
451
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
452
+ PUNCH - [alone] 1:[email protected] #ROOT2024
453
+ LITERAL Float 1.0 1:[email protected] #ROOT2024
454
+
455
+ -1.0"# ] ] ,
456
+ ) ;
457
+ check (
458
+ "@--1.0" ,
459
+ expect ! [ [ r#"
460
+ ExpandError {
461
+ inner: (
462
+
463
+ BindingError(
464
+ "expected literal",
465
+ ),
466
+ ),
467
+ }
468
+
469
+ SUBTREE $$ 1:[email protected] #ROOT2024 1:[email protected] #ROOT2024
470
+ PUNCH - [joint] 1:[email protected] #ROOT2024
471
+ PUNCH - [alone] 1:[email protected] #ROOT2024
472
+
473
+ --"# ] ] ,
474
+ ) ;
475
+ }
0 commit comments