Git Product home page Git Product logo

Comments (3)

halfdan avatar halfdan commented on May 28, 2024

There's no conversion happening. A list of digits that can be represented as a string just happens to be displayed as a string in iex. The list underneath is unchanged:

iex(1)> a = [65, 66, 67]
'ABC'
iex(2)> hd(a)
65

from ex_machina.

Liferenko avatar Liferenko commented on May 28, 2024

well, that's exactly why I created this issue :) Theory said it appears only in IEx, but practice showed chars in my list from ExMachina.sequence/2

Here is an example:

# test/support/data_case.ex
allowed_ids = [id_1 | _] = [next_id(), next_id(), next_id(), next_id()]

# test/support/factory.ex
use ExMachina.Ecto
def next_id, do: sequence(:id, & &1)

# run mix test.watch with dbg(allowed_ids) been added
#test A
    subject_info: %Context.SubjectInfo{                                                                                           
      user_token: "admin token",                                                                                                                            
      user_id: 389,                                                                                                                                         
      allowed_ids: 'STUV',                                                                                                                                     
      __unknown_fields__: [] 

#test B
    subject_info: %Context.SubjectInfo{
      user_token: "admin token",
      user_id: 1000,
      allowed_ids: '{|}~',
      __unknown_fields__: []
    },

#test C
    subject_info: %Context.SubjectInfo{                                                                                           
      user_token: "admin token",                                                                                                                            
      user_id: 802,                                                                                                                                         
      allowed_ids: '\a\b\t\n',                                                                                                                                 
      __unknown_fields__: []                                                                                                                                
    },                                                                                                                                  

#test D
    subject_info: %Context.SubjectInfo{
      user_token: "admin token",
      user_id: 31,
      allowed_ids: [0, 1, 2, 3],
      __unknown_fields__: []
    },

It looks like when you are using mix test.watch - it restart setup and re-generate a context with new allowed_ids. And after 8-10 restarts (test.watch restarts each time you save the file) when next_id's value go over 36, the list of ids goes to charlist instead of digits-only list (between 35-126).
After 126 it goes back to digits-only.

That's why when you try "Enum.member?(allowed_ids, 3)" it fails and said "allowed_ids = 'fghi'"

from ex_machina.

Liferenko avatar Liferenko commented on May 28, 2024

Looks like it was my fault and I made this issue ticket due to my lack of experience. Sorry. Falce alarm

from ex_machina.

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.