Write some tests #33

Merged
topchetoeu merged 13 commits from topchetoeu/tests into master 2025-01-15 18:23:25 +00:00
43 changed files with 58 additions and 74 deletions
Showing only changes of commit c0b23d50e5 - Show all commits

View File

@ -1,4 +1,4 @@
package me.topchetoeu.j2s.common.environment;
package me.topchetoeu.j2s.common;
import java.util.HashMap;
import java.util.HashSet;

View File

@ -1,4 +1,4 @@
package me.topchetoeu.j2s.common.mapping;
package me.topchetoeu.j2s.common;
import java.util.ArrayList;
import java.util.Arrays;
@ -13,8 +13,6 @@ import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
public class FunctionMap {

View File

@ -0,0 +1,3 @@
package me.topchetoeu.j2s.common;
public final class Key<T> { }

View File

@ -1,3 +0,0 @@
package me.topchetoeu.j2s.common.environment;
public final class Key<T> { }

View File

@ -1,14 +0,0 @@
package me.topchetoeu.j2s;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestHelloWorld {
@Test
public void testHelloWorld() {
final String message = "Hello World!";
assertEquals("Hello World!", message);
}
}

View File

@ -5,14 +5,14 @@ import java.util.Map;
import java.util.Stack;
import java.util.function.Function;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.FunctionBody;
import me.topchetoeu.j2s.common.FunctionMap;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.FunctionMap.FunctionMapBuilder;
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.common.mapping.FunctionMap;
import me.topchetoeu.j2s.common.mapping.FunctionMap.FunctionMapBuilder;
import me.topchetoeu.j2s.compilation.control.TryNode;
import me.topchetoeu.j2s.compilation.scope.FunctionScope;
import me.topchetoeu.j2s.compilation.scope.Variable;

View File

@ -2,10 +2,10 @@ package me.topchetoeu.j2s.compilation;
import java.util.List;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.compilation.parsing.ParseRes;
import me.topchetoeu.j2s.compilation.parsing.Parsing;
import me.topchetoeu.j2s.compilation.parsing.Source;

View File

@ -6,10 +6,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.common.SyntaxException;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.compilation.control.BreakNode;
import me.topchetoeu.j2s.compilation.control.ContinueNode;
import me.topchetoeu.j2s.compilation.control.DebugNode;

View File

@ -5,11 +5,11 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.function.IntSupplier;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.SyntaxException;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
public class LabelContext {
public static final Key<LabelContext> BREAK_CTX = new Key<>();

View File

@ -2,9 +2,9 @@ package me.topchetoeu.j2s.compilation.parsing;
import java.util.function.Predicate;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.environment.Environment;
public class Source {
public final Environment env;

View File

@ -5,9 +5,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.compilation.parsing.Source;
public class TestSource {

View File

@ -3,7 +3,7 @@ package me.topchetoeu.j2s.repl;
import java.util.HashSet;
import java.util.stream.Collectors;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.compilation.json.JSONElement;
import me.topchetoeu.j2s.compilation.json.JSONList;
import me.topchetoeu.j2s.compilation.json.JSONMap;

View File

@ -16,12 +16,12 @@ import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.common.Metadata;
import me.topchetoeu.j2s.common.Reading;
import me.topchetoeu.j2s.common.SyntaxException;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.compilation.JavaScript;
import me.topchetoeu.j2s.compilation.json.JSON;
import me.topchetoeu.j2s.compilation.parsing.Parsing;

View File

@ -7,7 +7,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.IntUnaryOperator;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.Frame;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.KeyCache;

View File

@ -11,15 +11,15 @@ import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.FunctionBody;
import me.topchetoeu.j2s.common.FunctionMap;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.Metadata;
import me.topchetoeu.j2s.common.Instruction.BreakpointType;
import me.topchetoeu.j2s.common.Instruction.Type;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.mapping.FunctionMap;
import me.topchetoeu.j2s.compilation.json.JSON;
import me.topchetoeu.j2s.compilation.json.JSONElement;
import me.topchetoeu.j2s.compilation.json.JSONList;

View File

@ -1,6 +1,6 @@
package me.topchetoeu.j2s.repl.debug;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.Frame;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.objects.ArrayLikeValue;

View File

@ -2,9 +2,9 @@ package me.topchetoeu.j2s.repl.mapping;
import java.util.function.Function;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.functions.FunctionValue;

View File

@ -2,10 +2,10 @@ package me.topchetoeu.j2s.runtime;
import java.util.function.Function;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.functions.FunctionValue;

View File

@ -3,9 +3,9 @@ package me.topchetoeu.j2s.runtime;
import java.util.concurrent.Future;
import java.util.function.Supplier;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.functions.FunctionValue;

View File

@ -4,9 +4,9 @@ import java.util.Arrays;
import java.util.Stack;
import java.util.concurrent.CancellationException;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.runtime.debug.DebugContext;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Value;

View File

@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Optional;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.Operation;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.functions.CodeFunction;

View File

@ -3,12 +3,12 @@ package me.topchetoeu.j2s.runtime.debug;
import java.util.HashMap;
import java.util.WeakHashMap;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.FunctionBody;
import me.topchetoeu.j2s.common.FunctionMap;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.common.mapping.FunctionMap;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.runtime.Frame;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Value;

View File

@ -1,10 +1,10 @@
package me.topchetoeu.j2s.runtime.debug;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Filename;
import me.topchetoeu.j2s.common.FunctionBody;
import me.topchetoeu.j2s.common.FunctionMap;
import me.topchetoeu.j2s.common.Instruction;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.mapping.FunctionMap;
import me.topchetoeu.j2s.runtime.Frame;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Value;

View File

@ -3,8 +3,8 @@ package me.topchetoeu.j2s.runtime.exceptions;
import java.util.ArrayList;
import java.util.List;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Location;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue.PrototypeProvider;

View File

@ -1,6 +1,6 @@
package me.topchetoeu.j2s.runtime.values;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.primitives.StringValue;
import me.topchetoeu.j2s.runtime.values.primitives.SymbolValue;
import me.topchetoeu.j2s.runtime.values.primitives.numbers.NumberValue;

View File

@ -2,7 +2,7 @@ package me.topchetoeu.j2s.runtime.values;
import java.util.Optional;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.functions.FunctionValue;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;
import me.topchetoeu.j2s.runtime.values.primitives.BoolValue;

View File

@ -14,9 +14,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.common.SyntaxException;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.runtime.EventLoop;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Member.PropertyMember;

View File

@ -1,7 +1,7 @@
package me.topchetoeu.j2s.runtime.values.functions;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;
import me.topchetoeu.j2s.runtime.values.primitives.UserValue;

View File

@ -1,7 +1,7 @@
package me.topchetoeu.j2s.runtime.values.functions;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.FunctionBody;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.runtime.Frame;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;

View File

@ -5,7 +5,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.debug.DebugContext;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.KeyCache;

View File

@ -1,6 +1,6 @@
package me.topchetoeu.j2s.runtime.values.functions;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.Value;
public final class NativeFunction extends FunctionValue {

View File

@ -7,7 +7,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.KeyCache;
import me.topchetoeu.j2s.runtime.values.Member;

View File

@ -6,7 +6,7 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.stream.Stream;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.primitives.VoidValue;

View File

@ -10,8 +10,8 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.environment.Key;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.Key;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.KeyCache;
import me.topchetoeu.j2s.runtime.values.Member;

View File

@ -2,7 +2,7 @@ package me.topchetoeu.j2s.runtime.values.objects.buffers;
import java.util.WeakHashMap;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.objects.ArrayLikeValue;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;

View File

@ -1,6 +1,6 @@
package me.topchetoeu.j2s.runtime.values.primitives;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;
import me.topchetoeu.j2s.runtime.values.primitives.numbers.NumberValue;

View File

@ -4,7 +4,7 @@ import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.KeyCache;
import me.topchetoeu.j2s.runtime.values.Member;
import me.topchetoeu.j2s.runtime.values.Value;

View File

@ -7,8 +7,8 @@ import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.common.StringifyUtils;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.runtime.values.KeyCache;
import me.topchetoeu.j2s.runtime.values.Member;
import me.topchetoeu.j2s.runtime.values.Member.FieldMember;

View File

@ -5,7 +5,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.Value;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;

View File

@ -7,7 +7,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.KeyCache;
import me.topchetoeu.j2s.runtime.values.Member;
import me.topchetoeu.j2s.runtime.values.Value;

View File

@ -4,7 +4,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.exceptions.EngineException;
import me.topchetoeu.j2s.runtime.values.KeyCache;
import me.topchetoeu.j2s.runtime.values.Member;

View File

@ -4,7 +4,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;
public final class IntValue extends NumberValue {

View File

@ -1,6 +1,6 @@
package me.topchetoeu.j2s.runtime.values.primitives.numbers;
import me.topchetoeu.j2s.common.environment.Environment;
import me.topchetoeu.j2s.common.Environment;
import me.topchetoeu.j2s.runtime.values.objects.ObjectValue;
import me.topchetoeu.j2s.runtime.values.primitives.PrimitiveValue;
import me.topchetoeu.j2s.runtime.values.primitives.StringValue;