Code Monkey home page Code Monkey logo

Comments (7)

snej avatar snej commented on June 26, 2024

FYI, the current Otto revision I'm testing is 04ea4a2. The one we've been using that works fine is adf21d0 from 5/15 ("No rush to change the interface of Value.Export()"). I'm running Go 1.1 on Mac OS X 10.8.4.

from otto.

snej avatar snej commented on June 26, 2024

If I call value.Type() at the start of ottoValueToStringArray(), the result is "GoArray". So it looks like the problem is in converting a JS GoArray back into a native Go array.

from otto.

robertkrimen avatar robertkrimen commented on June 26, 2024

Sorry about that. The problem is (probably) around here:

https://github.com/robertkrimen/otto/blob/master/value.go#L625

This is the commit that "broke" it:

6669f98

We have different types for a Go slice versus a Go array, now.

I'm not sure exactly why the export tests did not catch this, though...

from otto.

snej avatar snej commented on June 26, 2024

Maybe line 628 should read

if object.class == "Array” || object.class == “GoArray” {

?

from otto.

snej avatar snej commented on June 26, 2024

Yeah, that fixed it.

from otto.

snej avatar snej commented on June 26, 2024

The bug isn't fixed. My test is still failing — it's that assertion that I commented out when pasting it above. The result of Export is now correctly a string array, but unfortunately its value is nil :(

    channelmapper_test.go:33
    assert.DeepEquals(t, strings, []string{"foo", "bar", "baz"})    

    expected: []string{"foo", "bar", "baz"}
         got: []string(nil)
--- FAIL: TestOttoValueToStringArray (0.08 seconds)

The unit test you added (Test_issue24) doesn't catch this because it only verifies the return type, not the actual value.

from otto.

snej avatar snej commented on June 26, 2024

Oops, never mind — my own code was broken (it was still expecting Value to return []interface{}, not []string!)

from otto.

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.