Code Monkey home page Code Monkey logo

Comments (11)

brendanzab avatar brendanzab commented on May 21, 2024 1

Oh damn! That's because there is a global name generator that makes a special name that is unique for the entire program. The global state is in the nameless crate, which makes it quite hard to find!

I didn't want to use dependency injection for it, but perhaps I might need to.

Perhaps we could just leave those tests for now?

from pikelet.

brendanzab avatar brendanzab commented on May 21, 2024

Would you be interested in picking this up @adrianwong?

from pikelet.

adrianwong avatar adrianwong commented on May 21, 2024

Sure, I'll give it a shot @brendanzab!

from pikelet.

brendanzab avatar brendanzab commented on May 21, 2024

As some extra info, I'm expecting we'll probably want to use the fmt::Debug trait like so:

#[test]
fn ann_ann_right() {
     // Do we want this to be relative to the current test directory?
    let mut mint = Mint::new("tests/goldenfiles");
    let mut file = mint.new_goldenfile("ann_ann_right").unwrap();

    let term = parse(r"Type : (Type : Type)");

    write!(file, "{:#?}", term).unwrap();
}

The funny {:#?} will tell Rust to print out the value using an indented/pretty-printed output. This should work nicely for diffs when snapshot testing.

from pikelet.

brendanzab avatar brendanzab commented on May 21, 2024

Seems that this repo does all the golden tests in one test: https://github.com/slava-sh/rust-bundler/blob/master/tests/golden.rs

It would be interesting to see what the test failures looked like!

from pikelet.

adrianwong avatar adrianwong commented on May 21, 2024

I've hit a bit of a snag with the snapshot testing of the arrow, lam_ann, and pi tests in the desugar module. All three consistently fail snapshot testing due to the generation of a unique GenId(u32) struct on each run.

From what I am able to tell, the presence of the GenId node in the AST corresponds with nameless::bind( Name::user("_") ), but the rest is a bit beyond me.

Thoughts? What I've done so far can be found here.

from pikelet.

brendanzab avatar brendanzab commented on May 21, 2024

If you're curious, this is where the ids are generated (on the call to GenId::fresh):

concrete::Term::Arrow(ref ann, ref body) => {
let name = Name::from(GenId::fresh());
let ann = Rc::new(ann.desugar());
let body = Rc::new(body.desugar());
raw::Term::Pi(span, nameless::bind((name, Embed(ann)), body))
},

from pikelet.

brendanzab avatar brendanzab commented on May 21, 2024

Super neat thing is that it's showing that arrow types, eg. Int -> Int are actually just special cases of dependent functions/pi types/foralls: (x : Int) -> Int, where the parameter is not mentioned in the return type.

from pikelet.

adrianwong avatar adrianwong commented on May 21, 2024

Ah, whoops, I had it backwards. So in the tests when we parse, e.g. r"(x : Type -> Type) -> x", we then assert that the first Type has name x, whereas the second type doesn't have one, hence the Name::user("_")?

from pikelet.

adrianwong avatar adrianwong commented on May 21, 2024

Ok I'll leave the snapshot testing out for those three tests then!

from pikelet.

brendanzab avatar brendanzab commented on May 21, 2024

yup, spot on!

from pikelet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.