Overview
Comment: | Built test case to check if name mangling works. Implementation to follow. |
---|---|
Timelines: | family | ancestors | descendants | both | modules |
Files: | files | file ages | folders |
SHA3-256: |
8a801a61d4df3bee05680d450abb1da0 |
User & Date: | robin.hansen on 2021-02-05 14:46:26 |
Other Links: | branch diff | manifest | tags |
Context
2021-02-07
| ||
11:41 | Implement name mangling. check-in: 61c06857ee user: robin.hansen tags: modules | |
2021-02-05
| ||
14:46 | Built test case to check if name mangling works. Implementation to follow. check-in: 8a801a61d4 user: robin.hansen tags: modules | |
12:52 | Change how quote names are generated. check-in: 8c27f5a80c user: robin.hansen tags: modules | |
Changes
Modified tests/Test/Qualifier.elm from [c36fbff834] to [11ca4d912b].
636 637 638 639 640 641 642 643 |
[ Word emptyRange "False" ] } ] } |> QualifierUtil.addFunctionsForStructs in QualifierUtil.expectOutput unqualifiedAst expectedAst ] |
> > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 |
[ Word emptyRange "False" ] } ] } |> QualifierUtil.addFunctionsForStructs in QualifierUtil.expectOutput unqualifiedAst expectedAst , test "Name mangling" <| \_ -> let usMoneyUnion = [ Type.Custom "Dollar" , Type.Custom "Cent" ] unqualifiedAst = { types = Dict.fromListBy AST.typeDefinitionName [ AST.UnionTypeDef emptyRange "USMoney" [] usMoneyUnion , AST.CustomTypeDef emptyRange "Dollar" [] [ ( "dollar-value", Type.Int ) ] , AST.CustomTypeDef emptyRange "Cent" [] [ ( "cent-value", Type.Int ) ] ] , words = Dict.fromListBy .name [ { name = "into-cents" , metadata = Metadata.default |> Metadata.withType [ Type.Union usMoneyUnion ] [ Type.Union usMoneyUnion ] , implementation = AST.MultiImpl [ ( AST.TypeMatch emptyRange (Type.Custom "Dollar") [] , [ AST.Word emptyRange "dollar-value>" , AST.Integer emptyRange 100 , AST.Word emptyRange "*" ] ) , ( AST.TypeMatch emptyRange (Type.Custom "Cent") [] , [ AST.Word emptyRange "cent-value>" ] ) ] [] } , { name = "add-money" , metadata = Metadata.default |> Metadata.withType [ Type.Union usMoneyUnion, Type.Union usMoneyUnion ] [ Type.Union usMoneyUnion ] , implementation = AST.SoloImpl [ AST.Word emptyRange "into-cents" , AST.Word emptyRange "swap" , AST.Word emptyRange "into-cents" , AST.Word emptyRange "+" ] } , { name = "quote-excuse" , metadata = Metadata.default |> Metadata.withType [ Type.Custom "Dollar" ] [ Type.Custom "Dollar" ] , implementation = AST.SoloImpl [ AST.Word emptyRange "dollar-value>" , AST.Quotation emptyRange [ AST.Integer emptyRange 2 , AST.Word emptyRange "*" ] , AST.Word emptyRange "!" , AST.Word emptyRange ">Dollar" ] } ] } |> ParserUtil.addFunctionsForStructs expectedAst = { types = Dict.fromListBy typeDefinitionName [ UnionTypeDef "/play/test/some/module/USMoney" emptyRange [] usMoneyUnion , CustomTypeDef "/play/test/some/module/Dollar" emptyRange [] [ ( "dollar-value", Type.Int ) ] , CustomTypeDef "Cent" emptyRange [] [ ( "cent-value", Type.Int ) ] ] , words = Dict.fromListBy .name [ { name = "/play/test/some/module/into-cents" , metadata = Metadata.default |> Metadata.withType [ Type.Union usMoneyUnion ] [ Type.Union usMoneyUnion ] , implementation = MultiImpl [ ( TypeMatch emptyRange (Type.Custom "/play/test/some/module/Dollar") [] , [ Word emptyRange "/play/test/some/module/dollar-value>" , Integer emptyRange 100 , Builtin emptyRange Builtin.Multiply ] ) , ( TypeMatch emptyRange (Type.Custom "/play/test/some/module/Cent") [] , [ Word emptyRange "/play/test/some/module/cent-value>" ] ) ] [] } , { name = "/play/test/some/module/add-money" , metadata = Metadata.default |> Metadata.withType [ Type.Union usMoneyUnion, Type.Union usMoneyUnion ] [ Type.Union usMoneyUnion ] , implementation = SoloImpl [ Word emptyRange "/play/test/some/module/into-cents" , Builtin emptyRange Builtin.StackSwap , Word emptyRange "/play/test/some/module/into-cents" , Builtin emptyRange Builtin.Plus ] } , { name = "quote-excuse" , metadata = Metadata.default |> Metadata.withType [ Type.Custom "/play/test/some/module/Dollar" ] [ Type.Custom "/play/test/some/module/Dollar" ] , implementation = SoloImpl [ Word emptyRange "/play/test/some/module/dollar-value>" , WordRef emptyRange "quote:/play/test/some/module/quote-excuse/1" , Builtin emptyRange Builtin.Apply , Word emptyRange "/play/test/some/module/>Dollar" ] } , { name = "quote:/play/test/some/module/quote-excuse/1" , metadata = Metadata.default |> Metadata.isQuoted , implementation = SoloImpl [ Integer emptyRange 2 , Builtin emptyRange Builtin.Multiply ] } , { name = "/play/test/some/module/>Dollar" , metadata = Metadata.default |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/play/test/some/module/Dollar" ] , implementation = SoloImpl [ ConstructType "/play/test/some/module/Dollar" ] } , { name = "/play/test/some/module/>Cent" , metadata = Metadata.default |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/play/test/some/module/Cent" ] , implementation = SoloImpl [ ConstructType "/play/test/some/module/Cent" ] } , { name = "/play/test/some/module/>dollar-value" , metadata = Metadata.default |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Dollar", Type.Int ] [ Type.Custom "/play/test/some/module/Dollar" ] , implementation = SoloImpl [ SetMember "/play/test/some/module/Dollar" "dollar-value" ] } , { name = "/play/test/some/module/>cent-value" , metadata = Metadata.default |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Cent", Type.Int ] [ Type.Custom "/play/test/some/module/Cent" ] , implementation = SoloImpl [ SetMember "/play/test/some/module/Cent" "cent-value" ] } , { name = "/play/test/some/module/dollar-value>" , metadata = Metadata.default |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Dollar" ] [ Type.Int ] , implementation = SoloImpl [ GetMember "/play/test/some/module/Dollar" "dollar-value" ] } , { name = "/play/test/some/module/cent-value>" , metadata = Metadata.default |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Cent" ] [ Type.Int ] , implementation = SoloImpl [ GetMember "/play/test/some/module/Cent" "cent-value" ] } ] } in QualifierUtil.expectModuleOutput unqualifiedAst expectedAst ] |
Modified tests/Test/Qualifier/Util.elm from [aa4e67f4f9] to [14665d6907].
1
2
3
4
5
6
7
8
9
..
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
module Test.Qualifier.Util exposing
( addFunctionsForStructs
, expectOutput
)
import Dict
import Dict.Extra as Dict
import Expect exposing (Expectation)
import Play.Data.Metadata as Metadata
................................................................................
let
result =
AST.run
{ packageName = ""
, modulePath = ""
, ast = parserAst
}
in
case result of
Err errors ->
Expect.fail <| "Did not expect qualification to fail. Errors: " ++ Debug.toString errors
Ok actualAst ->
Expect.equal expectedAst actualAst
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
..
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
module Test.Qualifier.Util exposing ( addFunctionsForStructs , expectModuleOutput , expectOutput ) import Dict import Dict.Extra as Dict import Expect exposing (Expectation) import Play.Data.Metadata as Metadata ................................................................................ let result = AST.run { packageName = "" , modulePath = "" , ast = parserAst } in case result of Err errors -> Expect.fail <| "Did not expect qualification to fail. Errors: " ++ Debug.toString errors Ok actualAst -> Expect.equal expectedAst actualAst expectModuleOutput : Parser.AST -> AST -> Expectation expectModuleOutput parserAst expectedAst = let result = AST.run { packageName = "play/test" , modulePath = "some/module" , ast = parserAst } in case result of Err errors -> Expect.fail <| "Did not expect qualification to fail. Errors: " ++ Debug.toString errors Ok actualAst -> Expect.equal expectedAst actualAst |