content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Mon Mar 18 07:56:50 GMT 2024
   */
  
  package umd.cs.shop;
  
  import org.junit.jupiter.api.Test;
  import static org.junit.jupiter.api.Assertions.*;
  import org.junit.jupiter.api.Timeout;
  import java.util.concurrent.TimeUnit;
  import static org.evosuite.runtime.EvoAssertions.*;
  import java.util.Collection;
  import org.evosuite.runtime.EvoRunner;
  import org.evosuite.runtime.EvoRunnerParameters;
  import org.junit.runner.RunWith;
  import umd.cs.shop.JSSubstitution;
  import umd.cs.shop.JSTerm;
  
  @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true) 
  public class JSTerm_ESTest extends JSTerm_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testStandardizerTermReturningJSTermWhereIsEvalIsTrue() throws Throwable  {
        // Create a new JSTerm object and add an object to it
        JSTerm jSTerm = new JSTerm();
        jSTerm.add((Object) "%%%");
        
        // Make the JSTerm evaluate the added object
        jSTerm.makeEval(true);
        
        // Standardize the JSTerm to ensure it is in a consistent state
        jSTerm.standardizerTerm();
        
        // Assert that the JSTerm is now evaluating
        assertTrue(jSTerm.isEval());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsEvalReturningTrue() throws Throwable  {
        // Given a JSTerm object with makeEval set to true
        JSTerm jSTerm = new JSTerm();
        jSTerm.makeEval(true);
        
        // When the isEval method is called on the JSTerm object
        boolean eval = jSTerm.isEval();
        
        // Then the result of isEval should be true
        assertTrue(eval);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCloneTReturningJSTermWhereIsEvalIsTrue() throws Throwable  {
        // Tests that a JSTerm can be cloned and still evaluate expressions.
        JSTerm jSTerm = new JSTerm();
        jSTerm.add((Object) "Hello World");
        jSTerm.makeEval(true);
        assertTrue(jSTerm.isEval());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testApplySubstitutionTReturningJSTermWhereIsEvalIsTrue() throws Throwable  {
        JSTerm jTerm = new JSTerm();
        jTerm.add((Object) "Hello, world!");
        jTerm.makeEval(true);
        JSSubstitution arg0 = new JSSubstitution();
        jTerm.applySubstitutionT(arg0);
        // Check that the term has been evaluated successfully
        assertTrue(jTerm.isEval());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testEqualsThrowsArrayIndexOutOfBoundsException() throws Throwable  {
        JSTerm arg0 = new JSTerm();
        arg0.makeVariable();
        
        // Test that the equals method throws a NullPointerException when called with null argument
        try {
        arg0.equals(null);
        fail("Expecting exception: NullPointerException");
        } catch (NullPointerException e) {
        verifyException("java.util.Vector", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testMatchesTaking2ArgumentsThrowsArrayIndexOutOfBoundsException() throws Throwable  {
        JSTerm arg0 = new JSTerm();
        arg0.makeVariable();
        JSTerm jSTerm = new JSTerm();
        JSSubstitution arg1 = new JSSubstitution();
        
        // This test is checking that an ArrayIndexOutOfBoundsException is thrown when the argument to matches() is not a Vector
        assertThrows(ArrayIndexOutOfBoundsException.class, () -> {
        jSTerm.matches(arg0, arg1);});
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsVariable() throws Throwable  {
        // Given a JSTerm instance
        JSTerm jSTerm = new JSTerm();
        
        // When the isVariable method is called on the instance
        boolean variable = jSTerm.isVariable();
        
        // Then it should return false
        assertFalse(variable);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsConstant() throws Throwable  {
        // Given: a JavaScript term with no constant value
        JSTerm jsTerm = new JSTerm();
        
        // When: the isConstant method is called on the term
        boolean isConstant = jsTerm.isConstant();
        
        // Then: the method should return false, indicating that the term has no constant value
        assertFalse(isConstant);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCallThrowsArrayIndexOutOfBoundsException() throws Throwable  {
        // Given a JSTerm object with an uninitialized Vector
        JSTerm jsterm = new JSTerm();
        
        // When we add a String to the Vector and make it evaluable
        jsterm.add("%%%");
        jsterm.makeEval(true);
        
        // Then calling the Vector should throw an ArrayIndexOutOfBoundsException
        try {
        jsterm.call();
        fail("Expecting exception: ArrayIndexOutOfBoundsException");
        
        } catch (ArrayIndexOutOfBoundsException e) {
        // 1 >= 1
        verifyException("java.util.Vector", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCallReturningJSTermWhereSizeIsPositive() throws Throwable  {
        // Given: a JSTerm with a function call
        JSTerm arg0 = new JSTerm();
        arg0.add((Object) arg0);
        
        // When: the call method is called on the JSTerm
        JSTerm call = arg0.call();
        
        // Then: the call method returns a JSTerm with the correct value
        assertFalse(call.isVariable());
        assertFalse(call.isConstant());
        assertTrue(call.isFunction());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCallAndMakeEval() throws Throwable  {
        // Given a JSTerm object
        JSTerm jSTerm = new JSTerm();
        
        // When we make a variable and eval call
        jSTerm.makeVariable();
        jSTerm.makeEval(true);
        
        // Then the isEval method should return true
        assertTrue(jSTerm.isEval());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCallReturningJSTermWhereCapacityIsZero() throws Throwable  {
        // Create a new JSTerm instance
        JSTerm jsterm = new JSTerm();
        
        // Call the makeVariable method on the JSTerm instance
        jsterm.makeVariable();
        
        // Check that the isVariable method returns true after calling makeVariable
        assertTrue(jsterm.isVariable());
        
        // Call the call method on the JSTerm instance
        JSTerm called = jsterm.call();
        
        // Check that the isVariable method returns true after calling call
        assertTrue(called.isVariable());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testStandardizerTerm() throws Throwable  {
        // Given a new JSTerm object, arg0
        JSTerm arg0 = new JSTerm();
        
        // When we add the same object to the collection
        arg0.add((Object) arg0);
        
        // And then we standardize the term
        JSTerm standardizedTerm = arg0.standardizerTerm();
        
        // Then we expect the standardized term to be a copy of the original collection
        assertEquals("[[(this Collection)], [(this Collection)]]", standardizedTerm.toString());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsGroundReturningFalse() throws Throwable  {
        // Given a JSTerm object, with a single element that is itself a JSTerm object
        JSTerm arg0 = new JSTerm();
        arg0.add((Object) arg0);
        
        // When the standardizerTerm method is called on this JSTerm object
        JSTerm standardizerTerm = arg0.standardizerTerm();
        
        // Then the resulting JSTerm object should be a new object, with the same element as the original JSTerm object
        assertEquals(arg0, standardizerTerm);
        
        // And when the makeVariable method is called on this JSTerm object
        arg0.makeVariable();
        
        // Then the resulting JSTerm object should be a new object, with a variable as its element
        assertNotEquals(arg0, standardizerTerm);
        
        // When the addAll method is called on the standardizerTerm object, passing in the original JSTerm object
        standardizerTerm.addAll((Collection) arg0);
        
        // Then the resulting JSTerm object should be a new object, with the same element as the original JSTerm object, but in a different order
        assertEquals("[[(this Collection)], [(this Collection)]]", standardizerTerm.toString());
        
        // And when the isGround method is called on the resulting JSTerm object
        boolean ground = standardizerTerm.isGround();
        
        // Then the result should be false, as the JSTerm object contains a variable element
        assertFalse(ground);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsGround() throws Throwable  {
        // Given an instance of JSTerm, arg0
        JSTerm arg0 = new JSTerm();
        
        // When adding the same object to it twice
        arg0.add((Object) arg0);
        
        // Then the standardizer term is a JSTerm
        assertTrue(arg0.standardizerTerm() instanceof JSTerm);
        
        // And when adding all elements of the collection to the standardizer term
        arg0.standardizerTerm().addAll((Collection) arg0);
        
        // Then the ground property is true
        assertTrue(arg0.standardizerTerm().isGround());
        
        // And the string representation is as expected
        assertEquals("[[(this Collection)], [(this Collection)]]", arg0.standardizerTerm().toString());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testToStrThrowsNullPointerException() throws Throwable  {
        JSTerm jSTerm = new JSTerm();
        jSTerm.setSize(0);
        try {
        String toString = jSTerm.toString();
        fail("Expecting exception: NullPointerException");
        } catch (NullPointerException e) {
        // no message in exception (getMessage() returned null)
        verifyException("umd.cs.shop.JSTerm", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testMakeFunction() throws Throwable  {
        // Create a new JSTerm object and add it to itself
        JSTerm arg0 = new JSTerm();
        arg0.add((Object) arg0);
        
        // Create a new JSTerm object and make it a function
        JSTerm jSTerm = new JSTerm();
        arg0.makeFunction();
        
        // Check that the object is now a function
        assertTrue(arg0.isFunction());
        
        // Check that the object's equals method returns false when compared to itself as a function
        boolean equals = jSTerm.equals(arg0);
        assertFalse(equals);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testMakeVariable() throws Throwable  {
        // Test that a JSTerm instance can be created and has expected properties
        JSTerm term = new JSTerm();
        assertNotNull(term);
        assertTrue(term.isVariable()); // Check if the term is indeed a variable
        
        // Test that the term can be made equal to another variable
        JSTerm otherTerm = new JSTerm();
        boolean areEqual = term.equals(otherTerm);
        assertFalse(areEqual); // Check if the terms are not equal
        
        // Test that the term can be made equal to a non-variable object
        Object obj = new Object();
        areEqual = term.equals(obj);
        assertFalse(areEqual); // Check if the term is not equal to an arbitrary object
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testApplySubstitutionTReturningJSTermWhereIsEvalIsFalse() throws Throwable  {
        // Given
        JSTerm jSTerm = new JSTerm();
        
        // When
        jSTerm.add((Object) "Hello, world!");
        JSSubstitution arg0 = new JSSubstitution();
        JSTerm applySubstitutionT = jSTerm.applySubstitutionT(arg0);
        
        // Then
        assertFalse(applySubstitutionT.isVariable());
        assertFalse(applySubstitutionT.isEval());
        assertFalse(applySubstitutionT.isConstant());
        assertTrue(applySubstitutionT.isFunction());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCloneTReturningJSTermWhereIsEvalIsFalse() throws Throwable  {
        // Given a JSTerm object "arg0" with a single element
        JSTerm arg0 = new JSTerm();
        arg0.add((Object) arg0);
        
        // When the method "standardizerTerm" is called on "arg0"
        JSTerm standardizerTerm = arg0.standardizerTerm();
        
        // Then the result is a new JSTerm object with two elements
        assertEquals(2, standardizerTerm.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testPrint() throws Throwable  {
        // Test that a term can be evaluated recursively
        JSTerm term = new JSTerm();
        term.add((Object) term);
        term.makeEval(true);
        term.print();
        assertTrue(term.isEval());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testMatchesTakingJSTerm() throws Throwable  {
        // rollbacked to evosuite
        JSTerm arg0 = new JSTerm();
        JSSubstitution arg1 = arg0.matches(arg0);
        JSSubstitution matches = arg0.matches(arg0, arg1);
        assertTrue(arg1.fail());
        assertTrue(matches.fail());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testEqualsReturningFalse() throws Throwable  {
        // Create a new JSTerm object with default values.
        JSTerm arg0 = new JSTerm();
        
        // Test that the object is not equal to itself (reflexivity).
        boolean equals = arg0.equals(arg0);
        assertFalse(equals, "The object should not be equal to itself.");
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testMakeConstant() throws Throwable  {
        // Create a new JSTerm object
        JSTerm jSTerm = new JSTerm();
        
        // Make the term constant
        jSTerm.makeConstant();
        
        // Check if the term is ground
        boolean ground = jSTerm.isGround();
        
        // Assert that the term is a constant
        assertTrue(jSTerm.isConstant());
        
        // Assert that the term is ground
        assertTrue(ground);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testPrintThrowsArrayIndexOutOfBoundsException() throws Throwable  {
        JSTerm jSTerm = new JSTerm();
        jSTerm.makeVariable();
        // Test that the print() method throws an ArrayIndexOutOfBoundsException when called with an undeclared variable
        try {
        jSTerm.print();
        fail("Expecting exception: ArrayIndexOutOfBoundsException");
        
        } catch(ArrayIndexOutOfBoundsException e) {
        // Verify that the exception is of type java.util.Vector
        verifyException("java.util.Vector", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsEvalReturningFalse() throws Throwable  {
        // rollbacked to evosuite
        JSTerm jSTerm = new JSTerm();
        boolean eval = jSTerm.isEval();
        assertFalse(eval);
    }
  }
  