question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Write tests for immutableMap

See original GitHub issue

immutableMap is an internal module. It’s an abstract module. I wonder if anyone would be interested in writing tests for it. Note that we want to test the api, not the implementation (the type ImmutableMap is representing implementation), because the goal is to come up with better implementation with same functionality.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
dominictwleecommented, Nov 9, 2020

@dominictwlee Glad you start investigating it. So, the background of this work is to improve performance. If we have many atoms, our immutableMap becomes big which can cause bad performance of the entire library.

Originally, the code is embedded in Provider.ts, but as we move it to immutableMap.ts, we can compare different implementations. To compare different implementations, we need to test it (this issue) and measure peformance (#108).

As an example, the original implementation of immutable map is just a map which is copied on set.

const mCreate = () => new Map()
const mGet = (m, k) => m.get(k)
const mSet = (m, k, v) => new Map(m).set(k, v)
...

I still wonder if this is fairly performant.

So, the test would be something like this.

m1 = mCreate()
m2 = mSet(m1, 1, 'a')
mGet(m2, 1) === 'a'
mGet(m1, 1) === undefined // or == null? or !== 'a'
m1 !== m2
m3 = mSet(m2, 1, 'b')
mGet(m2, 1) === 'a'
...

Does it clarify the idea?

Yep makes sense, looks similar to some of the test cases I drafted out. Cool I know where to take it from here, thanks!

1reaction
dominictwleecommented, Nov 9, 2020

Cool, I’ll have a look at it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java example source code file (ImmutableMapTest.java)
This example Java source code file (ImmutableMapTest.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this ...
Read more >
guava-tests/test/com/google/common/collect/MapsTest.java
Unless required by applicable law or agreed to in writing, software ... Unit test for {@code Maps}. ... Map<Integer, String> right = ImmutableMap.of(....
Read more >
Immutable Map in Java - GeeksforGeeks
ImmutableMap, as suggested by the name, is a type of Map which is immutable. It means that the content of the map are...
Read more >
How to test immutable Map using React Jest? - Stack Overflow
I would like to test it using Jest/Enzyme but I can't change name prop. What is the proper way to test immutable Map?...
Read more >
com.google.common.collect.ImmutableMap.of java code ...
thenReturn(ImmutableMap.of("key", Boolean.TRUE));. ... @Test public void testSelectCount() throws Exception { final ResultSet resultSet = client.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found