|
1 | 1 | using clojure.lang.TypeName2; |
2 | 2 | using NUnit.Framework; |
| 3 | +using System; |
3 | 4 | using System.Collections.Generic; |
4 | 5 | using System.Linq; |
5 | 6 |
|
@@ -330,7 +331,7 @@ public void GenericParams_ParsesCorrectly() |
330 | 331 | [Test] |
331 | 332 | public void SimpleNestedGeneric_ParsesCorrectly() |
332 | 333 | { |
333 | | - var spec = ClrTypeSpec.Parse("A[T]+B]"); |
| 334 | + var spec = ClrTypeSpec.Parse("A[T]+B"); |
334 | 335 | var cmp = TypeSpecComparer.Create("A", 1) |
335 | 336 | .WithNested("B") |
336 | 337 | .WithGenericParams( |
@@ -378,6 +379,13 @@ public void SimpleNestedGeneric_ParsesCorrectly() |
378 | 379 | Assert.That(cmp.SameAs(spec), Is.True); |
379 | 380 | } |
380 | 381 |
|
| 382 | + [Test] |
| 383 | + public void NestedGenericProcessesTerminatingCharacter() |
| 384 | + { |
| 385 | + var exn = Assert.Throws<ArgumentException>(() => ClrTypeSpec.Parse("A[T]+B]")); |
| 386 | + Assert.That(exn.Message, Does.Contain("Unmatched ']'")); |
| 387 | + } |
| 388 | + |
381 | 389 |
|
382 | 390 | [Test] |
383 | 391 | public void NestedGenericWithModifiers_ParsesCorrectly() |
@@ -448,6 +456,153 @@ public void NestedGenericAsGenericArg_ParsesCorrectly() |
448 | 456 | Assert.That(cmp.SameAs(spec), Is.True); |
449 | 457 | } |
450 | 458 |
|
| 459 | + |
| 460 | + [Test] |
| 461 | + public void NestedGenericWithAssembly_ParsesCorrectly() |
| 462 | + { |
| 463 | + var spec = ClrTypeSpec.Parse("A[T]+B, AssemblyA"); |
| 464 | + var cmp = TypeSpecComparer.Create("A", 1) |
| 465 | + .WithAssembly("AssemblyA") |
| 466 | + .WithNested("B") |
| 467 | + .WithGenericParams( |
| 468 | + TypeSpecComparer.Create("T")); |
| 469 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 470 | + |
| 471 | + spec = ClrTypeSpec.Parse("A+B[T], AssemblyA"); |
| 472 | + cmp = TypeSpecComparer.Create("A") |
| 473 | + .WithAssembly("AssemblyA") |
| 474 | + .WithNested(("B", 1)) |
| 475 | + .WithGenericParams( |
| 476 | + TypeSpecComparer.Create("T")); |
| 477 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 478 | + |
| 479 | + spec = ClrTypeSpec.Parse("A+B[T]+C, AssemblyA"); |
| 480 | + cmp = TypeSpecComparer.Create("A") |
| 481 | + .WithAssembly("AssemblyA") |
| 482 | + .WithNested(("B", 1), ("C", 0)) |
| 483 | + .WithGenericParams( |
| 484 | + TypeSpecComparer.Create("T")); |
| 485 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 486 | + |
| 487 | + spec = ClrTypeSpec.Parse("A+B+C[T], AssemblyA"); |
| 488 | + cmp = TypeSpecComparer.Create("A") |
| 489 | + .WithAssembly("AssemblyA") |
| 490 | + .WithNested(("B", 0), ("C", 1)) |
| 491 | + .WithGenericParams( |
| 492 | + TypeSpecComparer.Create("T")); |
| 493 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 494 | + |
| 495 | + |
| 496 | + spec = ClrTypeSpec.Parse("A+B[T]+C[U,V], AssemblyA"); |
| 497 | + cmp = TypeSpecComparer.Create("A") |
| 498 | + .WithAssembly("AssemblyA") |
| 499 | + .WithNested(("B", 1), ("C", 2)) |
| 500 | + .WithGenericParams( |
| 501 | + TypeSpecComparer.Create("T"), |
| 502 | + TypeSpecComparer.Create("U"), |
| 503 | + TypeSpecComparer.Create("V")); |
| 504 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 505 | + |
| 506 | + spec = ClrTypeSpec.Parse("A[T]+B+C+D[U,V]+E, AssemblyA"); |
| 507 | + cmp = TypeSpecComparer.Create("A", 1) |
| 508 | + .WithAssembly("AssemblyA") |
| 509 | + .WithNested(("B", 0), ("C", 0), ("D", 2), ("E", 0)) |
| 510 | + .WithGenericParams( |
| 511 | + TypeSpecComparer.Create("T"), |
| 512 | + TypeSpecComparer.Create("U"), |
| 513 | + TypeSpecComparer.Create("V")); |
| 514 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 515 | + } |
| 516 | + |
| 517 | + [Test] |
| 518 | + public void NestedGenericWithAssemblyWithModifiers_ParsesCorrectly() |
| 519 | + { |
| 520 | + var spec = ClrTypeSpec.Parse("A[T][], AssemblyA"); |
| 521 | + var cmp = TypeSpecComparer.Create("A", 1) |
| 522 | + .WithAssembly("AssemblyA") |
| 523 | + .WithGenericParams( |
| 524 | + TypeSpecComparer.Create("T")) |
| 525 | + .WithModifiers(new ClrArraySpec(1, false)); |
| 526 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 527 | + |
| 528 | + |
| 529 | + spec = ClrTypeSpec.Parse("A[T]+B+C+D[U,V]+E[], AssemblyA"); |
| 530 | + cmp = TypeSpecComparer.Create("A", 1) |
| 531 | + .WithAssembly("AssemblyA") |
| 532 | + .WithNested(("B", 0), ("C", 0), ("D", 2), ("E", 0)) |
| 533 | + .WithGenericParams( |
| 534 | + TypeSpecComparer.Create("T"), |
| 535 | + TypeSpecComparer.Create("U"), |
| 536 | + TypeSpecComparer.Create("V")) |
| 537 | + .WithModifiers(new ClrArraySpec(1, false)); |
| 538 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 539 | + |
| 540 | + spec = ClrTypeSpec.Parse("A[T]+B+C+D[U,V]+E[,]**&, AssemblyA"); |
| 541 | + cmp = TypeSpecComparer.Create("A", 1) |
| 542 | + .WithAssembly("AssemblyA") |
| 543 | + .WithNested(("B", 0), ("C", 0), ("D", 2), ("E", 0)) |
| 544 | + .WithGenericParams( |
| 545 | + TypeSpecComparer.Create("T"), |
| 546 | + TypeSpecComparer.Create("U"), |
| 547 | + TypeSpecComparer.Create("V")) |
| 548 | + .WithModifiers(new ClrArraySpec(2, false), new ClrPointerSpec(2)) |
| 549 | + .SetIsByRef(); |
| 550 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 551 | + } |
| 552 | + |
| 553 | + [Test] |
| 554 | + public void NestedGenericWithAseemblyAsGenericArg_ParsesCorrectly() |
| 555 | + { |
| 556 | + var spec = ClrTypeSpec.Parse("A[[B+C[T],AssemblyB]], AssemblyA"); |
| 557 | + var cmp = TypeSpecComparer.Create("A", 1) |
| 558 | + .WithAssembly("AssemblyA") |
| 559 | + .WithGenericParams( |
| 560 | + TypeSpecComparer.Create("B").WithNested(("C", 1)) |
| 561 | + .WithAssembly("AssemblyB") |
| 562 | + .WithGenericParams( |
| 563 | + TypeSpecComparer.Create("T"))); |
| 564 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 565 | + |
| 566 | + |
| 567 | + spec = ClrTypeSpec.Parse("A[[B+C[T]+D, AssemblyB]], AssemblyA"); |
| 568 | + cmp = TypeSpecComparer.Create("A", 1) |
| 569 | + .WithAssembly("AssemblyA") |
| 570 | + .WithGenericParams( |
| 571 | + TypeSpecComparer.Create("B").WithNested(("C", 1), ("D", 0)) |
| 572 | + .WithAssembly("AssemblyB") |
| 573 | + .WithGenericParams( |
| 574 | + TypeSpecComparer.Create("T"))); |
| 575 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 576 | + |
| 577 | + |
| 578 | + spec = ClrTypeSpec.Parse("A[[B+C[T], AssemblyB]]+D, AssemblyA"); |
| 579 | + cmp = TypeSpecComparer.Create("A", 1) |
| 580 | + .WithAssembly("AssemblyA") |
| 581 | + .WithNested("D") |
| 582 | + .WithGenericParams( |
| 583 | + TypeSpecComparer.Create("B").WithNested(("C", 1)) |
| 584 | + .WithAssembly("AssemblyB") |
| 585 | + .WithGenericParams( |
| 586 | + TypeSpecComparer.Create("T"))); |
| 587 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 588 | + |
| 589 | + |
| 590 | + spec = ClrTypeSpec.Parse("A[[B+C[T], AssemblyB],[D[U]+E, AssemblyD]]+F, AssemblyA"); |
| 591 | + cmp = TypeSpecComparer.Create("A", 2) |
| 592 | + .WithAssembly("AssemblyA") |
| 593 | + .WithNested("F") |
| 594 | + .WithGenericParams( |
| 595 | + TypeSpecComparer.Create("B") |
| 596 | + .WithAssembly("AssemblyB") |
| 597 | + .WithNested(("C", 1)) |
| 598 | + .WithGenericParams(TypeSpecComparer.Create("T")), |
| 599 | + TypeSpecComparer.Create("D", 1) |
| 600 | + .WithAssembly("AssemblyD") |
| 601 | + .WithNested("E") |
| 602 | + .WithGenericParams(TypeSpecComparer.Create("U"))); |
| 603 | + Assert.That(cmp.SameAs(spec), Is.True); |
| 604 | + } |
| 605 | + |
451 | 606 | [Test] |
452 | 607 | public void GenericArg_CannotBeByRef() |
453 | 608 | { |
|
0 commit comments