Giter Club home page Giter Club logo

fcalib's Introduction

  • ๐Ÿ‘‹ Hi, I'm @julianmendez .
  • ๐Ÿ‘€ I'm interested in logic, mathematics, and computer science.
  • ๐ŸŒฑ I'm currently learning about proof checkers.
  • ๐Ÿ’ž๏ธ I'm looking to collaborate on ethics and artificial intelligence.
  • ๐Ÿ“ซ How to reach me : https://www.umu.se/en/staff/julian-mendez/

fcalib's People

Contributors

francesco-kriegel avatar julianmendez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fcalib's Issues

ListSet: addAll() and removeAll() unexpected behavior

In using the ListSet#addAll(Collection<? extends T> c) we've run into unexpected behavior where only the first element of the collection c is added. We've encountered similar behavior in the ListSet#removeAll(Collection<?> c) method, except it seems to hang. We think both are due to a short circuit in the logical OR the methods employ.

Test class to reproduce:

class ListSetTest {

    private ListSet<Object> listSet;

    private Object objA;
    private Object objB;
    private Object objC;

    private Set<Object> testSet;

    @BeforeEach
    void init() {
        listSet = new ListSet<>();

        objA = new Object();
        objB = new Object();
        objC = new Object();

        testSet = new HashSet<>(Arrays.asList(objA, objB, objC));
    }

    @Test
    @Disabled("Seems to have a conditional short circuit")
    void testAddAll() {
        listSet.addAll(testSet); // only adds first
        assertEquals(3, listSet.size()); // 1
    }

    @Test
    @Disabled("Loops: Seems to have a conditional short circuit")
    void testRemoveAll() {
        listSet.add(objA);
        listSet.add(objB);
        listSet.add(objC);
        listSet.removeAll(testSet); // hangs
        assertEquals(0, listSet.size());
    }
}

Formal and Partial Context: remove(I id) throws NullPointerException for non-existent objects

FormalContext and PartialContext both throw a NullPointerException when attempting to remove an object not present in the context by the object's id.

The code is equivalent:

@Override
public boolean removeObject(I id) throws IllegalObjectException {
	boolean removed = getObjects().remove(getObject(id));
	if (!removed) {
		throw new IllegalObjectException("Object" + id + "not successfully removed");
	}
	return true;
}

On the first line, getObject(id) returns null for the non-existent object. Since the objects are held in a ListSet, getObjects().remove(...) calls ListSet's overridden remove(Object o) method.

ListSet#remove():

@Override
public boolean remove(Object o) throws NullPointerException {
	if (o == null) {
		throw new NullPointerException();
	}
	if (contains(o)) {
		this.elements.remove(o);
		return true;
	}
	return false;
}

As o is null, the NullPointerException is thrown instead of the IllegalObjectException that is expected.

Test to reproduce:

@Test
@Disabled("Throws NullPointerException")
void testRemoveObject() throws IllegalObjectException {
    PartialObject<Integer, String> pObjA = new PartialObject<>("a");
    PartialObject<Integer, String> pObjB = new PartialObject<>("b");

    PartialContext<Integer, String, PartialObject<Integer, String>> context = new PartialContext<>();

    context.addObject(pObjA);
    assertThrows(IllegalObjectException.class, () -> context.removeObject("b"));
}

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.