Play

Check-in [d4ac6cbece]
Login
Overview
Comment:Add test for compilation failure found in playground.
Timelines: family | ancestors | descendants | both | bugfix-generics-and-quotations
Files: files | file ages | folders
SHA3-256: d4ac6cbeceaec81863476cf1eb90bb5be680ca4cb776bc0802eda07e560d6620
User & Date: robin.hansen on 2020-11-17 14:42:27
Other Links: branch diff | manifest | tags
Context
2020-11-19
05:53
Make use of type annotations when type checking words. This allows for a workaround with stack range... check-in: 63296cf7f2 user: robin.hansen tags: bugfix-generics-and-quotations
2020-11-17
14:42
Add test for compilation failure found in playground. check-in: d4ac6cbece user: robin.hansen tags: bugfix-generics-and-quotations
2020-10-23
04:46
TypeChecker now checks to see if a multiword handles every possible leading type. Fixes [56a0fe1350]... check-in: dbcb88d2fc user: robin.hansen tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified tests/Test/TypeChecker.elm from [ba577d7cfb] to [5ce2f71b87].

5
6
7
8
9
10
11

12
13
14
15
16
17
18
...
382
383
384
385
386
387
388

















































































































389
390
391
392
393
394
395
import Expect
import Play.Data.Builtin as Builtin
import Play.Data.Metadata as Metadata exposing (Metadata)
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type
import Play.Qualifier as QAST
import Play.TypeChecker exposing (..)

import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "TypeChecker"
        [ test "Simple program" <|
................................................................................
                                ]
                        }
                in
                case run input of
                    Err _ ->
                        Expect.fail "Did not expect type check to fail."


















































































































                    Ok _ ->
                        Expect.pass
        , test "Generic custom type fails if not generic is listed" <|
            \_ ->
                let
                    input =
                        { types =







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
import Expect
import Play.Data.Builtin as Builtin
import Play.Data.Metadata as Metadata exposing (Metadata)
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type
import Play.Qualifier as QAST
import Play.TypeChecker exposing (..)
import Play.TypeChecker.Problem as Problem
import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "TypeChecker"
        [ test "Simple program" <|
................................................................................
                                ]
                        }
                in
                case run input of
                    Err _ ->
                        Expect.fail "Did not expect type check to fail."

                    Ok _ ->
                        Expect.pass
        , test "Generic types with rotations and quotations" <|
            \_ ->
                let
                    input =
                        { types =
                            Dict.fromListBy QAST.typeDefinitionName
                                [ QAST.CustomTypeDef "Coordinate"
                                    emptyRange
                                    []
                                    [ ( "x", Type.Int )
                                    , ( "y", Type.Int )
                                    ]
                                ]
                        , words =
                            Dict.fromListBy .name
                                [ { name = "main"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType [] [ Type.Int ]
                                  , implementation =
                                        QAST.SoloImpl
                                            [ QAST.Integer emptyRange 1
                                            , QAST.Integer emptyRange 2
                                            , QAST.Word emptyRange ">Coordinate"
                                            , QAST.WordRef emptyRange "main__quot1"
                                            , QAST.Word emptyRange "update-x"
                                            , QAST.Word emptyRange "x>"
                                            ]
                                  }
                                , { name = "main__quot1"
                                  , metadata = Metadata.default
                                  , implementation =
                                        QAST.SoloImpl
                                            [ QAST.Integer emptyRange 1
                                            , QAST.Builtin emptyRange Builtin.Plus
                                            ]
                                  }
                                , { name = "update-x"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Custom "Coordinate"
                                                , Type.Quotation { input = [ Type.Int ], output = [ Type.Int ] }
                                                ]
                                                [ Type.Custom "Coordinate" ]
                                  , implementation =
                                        QAST.SoloImpl
                                            [ QAST.Builtin emptyRange Builtin.StackSwap
                                            , QAST.Builtin emptyRange Builtin.StackDuplicate
                                            , QAST.Word emptyRange "x>"
                                            , QAST.Builtin emptyRange Builtin.StackLeftRotate
                                            , QAST.Builtin emptyRange Builtin.Apply
                                            , QAST.Word emptyRange ">x"
                                            ]
                                  }
                                , { name = ">Coordinate"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType [ Type.Int, Type.Int ] [ Type.Custom "Coordinate" ]
                                  , implementation =
                                        QAST.SoloImpl
                                            [ QAST.ConstructType "Coordinate"
                                            ]
                                  }
                                , { name = ">x"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Custom "Coordinate", Type.Int ]
                                                [ Type.Custom "Coordinate" ]
                                  , implementation =
                                        QAST.SoloImpl [ QAST.SetMember "Coordinate" "x" ]
                                  }
                                , { name = "x>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Custom "Coordinate" ]
                                                [ Type.Int ]
                                  , implementation =
                                        QAST.SoloImpl [ QAST.GetMember "Coordinate" "x" ]
                                  }
                                , { name = ">y"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Custom "Coordinate", Type.Int ]
                                                [ Type.Custom "Coordinate" ]
                                  , implementation =
                                        QAST.SoloImpl [ QAST.SetMember "Coordinate" "y" ]
                                  }
                                , { name = "y>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Custom "Coordinate" ]
                                                [ Type.Int ]
                                  , implementation =
                                        QAST.SoloImpl [ QAST.GetMember "Coordinate" "y" ]
                                  }
                                ]
                        }
                in
                case run input of
                    Err err ->
                        err
                            |> List.map (Problem.toString "")
                            |> String.join "\n"
                            |> (++) "Did not expect type check to fail.\n"
                            |> Expect.fail

                    Ok _ ->
                        Expect.pass
        , test "Generic custom type fails if not generic is listed" <|
            \_ ->
                let
                    input =
                        { types =