Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include generics to get test cases working #166

Merged
merged 39 commits into from
Dec 15, 2022
Merged

Conversation

MicroProofs
Copy link
Member

No description provided.

@MicroProofs MicroProofs changed the title Some interesting test cases Include generics to get test cases working Dec 11, 2022
@MicroProofs MicroProofs marked this pull request as ready for review December 13, 2022 02:38
@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from 145dc5b to 6bf313a Compare December 13, 2022 10:23
@KtorZ
Copy link
Member

KtorZ commented Dec 13, 2022

Rebased, added a new test (tried to work around test c by declaring the lambda as a named function but ran into a new unseen compiler crash, so I added it as a new test case d), and fixed the examples to use the new syntax for generics.

@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from 6bf313a to 5c94f80 Compare December 13, 2022 13:09
@rvcas rvcas force-pushed the some-interesting-test-cases branch 2 times, most recently from db4784c to 8af4685 Compare December 13, 2022 15:39
@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from 8af4685 to c8f3def Compare December 13, 2022 15:41
KtorZ added a commit to aiken-lang/stdlib that referenced this pull request Dec 13, 2022
  Few TODOs from there:

  - [] Seems like the parser can't parse negative literals.
    Current work-around: write as `0 - n` instead of `-n`.

  - [] The formatter confuses tuples with function arguments
    in expression blocks. So writing:

    ```
    let (xs, ys) = unzip(rest)
    ([x, ..xs], [y, ..ys])
    ```

    is wrongly turned into:

    ```
    let (xs, ys) = unzip(rest)([x, ..xs], [y, ..ys])
    ```

  - [] Inline comments and function documentation comments are wrongly
    grouped together by the formatter.

  - [] The compiler panicks when two tests have the same name:

    ```
    test foo() { todo }
    test foo() { todo }
    ```

    ```
    Error:
      × Main thread panicked.
      ├─▶ at crates/lang/src/tipo/infer.rs:181:43
      ╰─▶ Could not find hydrator for fn
      help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
    ```

  - As well as any acceptance tests added to: aiken-lang/aiken#166
KtorZ and others added 19 commits December 14, 2022 09:45
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:3264:35
    ╰─▶ called `Option::unwrap()` on a `None` value
    help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
  ```
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:1518:45
    ╰─▶ called `Option::unwrap()` on a `None` value
    help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
  ```
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:4043:46
    ╰─▶ not yet implemented
    help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
  ```
…{1,2,3,4,5,6}

  Also added a little Makefile to run them all in one go.
  ```
  Error: aiken::check

    × Checking
    ╰─▶ Not a function
     ╭─[./007/lib/test.ak:4:1]
   4 │     [(a, b), ..rest] -> {
   5 │       let (a_tail, b_tail) = unzip(rest)
     ·                                   ──────
   6 │       ([a, ..a_tail], [b, ..b_tail])
     ╰────
  ```
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:530:41
    ╰─▶ not yet implemented
    help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
  ```
  Note: the problem is only present when importing a builtin explicitly.
  When using a qualified import, it compiles fine.

  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:3264:35
    ╰─▶ called `Option::unwrap()` on a `None` value
    help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
  ```
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:688:33
    ╰─▶ called `Option::unwrap()` on a `None` value
    help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
  ```
KtorZ and others added 8 commits December 14, 2022 09:45
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:4022:40
    ╰─▶ called `Option::unwrap()` on a `None` value
  ```
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:3413:34
    ╰─▶ internal error: entered unreachable code: Var {
            scope: [
                0,
                1,
                3,
                24,
                25,
                29,
                32,
            ],
            constructor: ValueConstructor {
                public: false,
                variant: LocalVariable {
                    location: 46..62,
                },
                tipo: Fn {
                    args: [
                        Var {
                            tipo: RefCell {
                                value: Link {
                                    tipo: App {
                                        public: true,
                                        module: "",
                                        name: "Int",
                                        args: [],
                                    },
                                },
                            },
                        },
                    ],
                    ret: App {
                        public: true,
                        module: "",
                        name: "Bool",
                        args: [],
                    },
                },
            },
            name: "f",
            variant_name: "",
        }
  ```
  ```
  ERROR:
  The provided Plutus code called 'error'
  ```
  Pretty useful for debbugging. Though, on second-thoughts, this is
  something we may want to review later and maybe have that done by
  default for tests.

  At the moment, we expects tests to unify to `bool`, and treat `false`
  values as failing tests. Yet, on failures, this gives little
  information about what's wrong with the test.

  It'd be nice to either have better way to assert in tests, or, to
  simply accept non-bool tests, and show whatever the test evaluates
  to as a debug output.
@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from 3541bad to 3c664b9 Compare December 14, 2022 08:45
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:2388:21
    ╰─▶ not yet implemented
  ```
@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from 6bc5806 to bd956ef Compare December 14, 2022 09:20
KtorZ added a commit to aiken-lang/stdlib that referenced this pull request Dec 14, 2022
  Few TODOs from there:

  - [] Seems like the parser can't parse negative literals.
    Current work-around: write as `0 - n` instead of `-n`.

  - [] The formatter confuses tuples with function arguments
    in expression blocks. So writing:

    ```
    let (xs, ys) = unzip(rest)
    ([x, ..xs], [y, ..ys])
    ```

    is wrongly turned into:

    ```
    let (xs, ys) = unzip(rest)([x, ..xs], [y, ..ys])
    ```

  - [] Inline comments and function documentation comments are wrongly
    grouped together by the formatter.

  - [] The compiler panicks when two tests have the same name:

    ```
    test foo() { todo }
    test foo() { todo }
    ```

    ```
    Error:
      × Main thread panicked.
      ├─▶ at crates/lang/src/tipo/infer.rs:181:43
      ╰─▶ Could not find hydrator for fn
      help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
    ```

  - As well as any acceptance tests added to: aiken-lang/aiken#166
@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from cf4bf64 to 87546e0 Compare December 14, 2022 17:44
  Was introduced as a work-around to get some debugging info out of scripts, but tests do now provide the same capability with a better output and, do so automatically.
@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from 3a21167 to e597264 Compare December 14, 2022 21:14
@KtorZ KtorZ force-pushed the some-interesting-test-cases branch from 38d44d9 to 5024bd8 Compare December 15, 2022 01:02
Copy link
Member

@KtorZ KtorZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving on with merging that one as-is, as it contains quite a few utilities for testing; useful to setup a continuous integration workflow on stdlib

@KtorZ KtorZ merged commit d9d1310 into main Dec 15, 2022
@KtorZ KtorZ deleted the some-interesting-test-cases branch December 15, 2022 01:07
@rvcas rvcas added the code gen Untyped Plutus Core code generation label Dec 15, 2022
@rvcas rvcas added this to the v0.1.0 - Initial Alpha milestone Dec 15, 2022
@KtorZ KtorZ mentioned this pull request Dec 20, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code gen Untyped Plutus Core code generation
Projects
Status: 🚀 Released
Development

Successfully merging this pull request may close these issues.

None yet

3 participants