The source code to test.
An array of string array. Each slot represents the variable name followed by the type strings.
Parses source, caches its symbols and compares the the cache content with the results.
Params: source = The source code to test. results = An array of string array. Each slot represents the variable name followed by the type strings.
writeln("Running type deduction tests..."); q{bool b; int i;}.expectSymbolsAndTypes([["b", "bool"],["i", "int"]]); q{auto b = false;}.expectSymbolsAndTypes([["b", "bool"]]); q{auto b = true;}.expectSymbolsAndTypes([["b", "bool"]]); q{auto b = [0];}.expectSymbolsAndTypes([["b", "*arr*", "int"]]); q{auto b = [[0]];}.expectSymbolsAndTypes([["b", "*arr*", "*arr*", "int"]]); q{auto b = [[[0]]];}.expectSymbolsAndTypes([["b", "*arr*", "*arr*", "*arr*", "int"]]); //q{int* b;}.expectSymbolsAndTypes([["b", "*", "int"]]); //q{int*[] b;}.expectSymbolsAndTypes([["b", "*arr*", "*", "int"]]);
Parses source, caches its symbols and compares the the cache content with the results.
Params: source = The source code to test. results = An array of string array. Each slot represents the variable name followed by the type strings.
ModuleCache cache = ModuleCache(theAllocator); writeln("Running struct constructor tests..."); auto source = q{ struct A {int a; struct B {bool b;} int c;} }; auto pair = generateAutocompleteTrees(source, cache); auto A = pair.symbol.getFirstPartNamed(internString("A")); auto B = A.getFirstPartNamed(internString("B")); auto ACtor = A.getFirstPartNamed(CONSTRUCTOR_SYMBOL_NAME); auto BCtor = B.getFirstPartNamed(CONSTRUCTOR_SYMBOL_NAME); assert(ACtor.callTip == "this(int a, int c)"); assert(BCtor.callTip == "this(bool b)");
Parses source, caches its symbols and compares the the cache content with the results.
Params: source = The source code to test. results = An array of string array. Each slot represents the variable name followed by the type strings.
ModuleCache cache = ModuleCache(theAllocator); writeln("Running union constructor tests..."); auto source = q{ union A {int a; bool b;} }; auto pair = generateAutocompleteTrees(source, cache); auto A = pair.symbol.getFirstPartNamed(internString("A")); auto ACtor = A.getFirstPartNamed(CONSTRUCTOR_SYMBOL_NAME); assert(ACtor.callTip == "this(int a, bool b)");
Parses source, caches its symbols and compares the the cache content with the results.
Params: source = The source code to test. results = An array of string array. Each slot represents the variable name followed by the type strings.
ModuleCache cache = ModuleCache(theAllocator); writeln("Running non-importable symbols tests..."); auto source = q{ class A { this(int a){} } class B : A {} class C { A f; alias f this; } }; auto pair = generateAutocompleteTrees(source, cache); auto A = pair.symbol.getFirstPartNamed(internString("A")); auto B = pair.symbol.getFirstPartNamed(internString("B")); auto C = pair.symbol.getFirstPartNamed(internString("C")); assert(A.getFirstPartNamed(CONSTRUCTOR_SYMBOL_NAME) !is null); assert(B.getFirstPartNamed(CONSTRUCTOR_SYMBOL_NAME) is null); assert(C.getFirstPartNamed(CONSTRUCTOR_SYMBOL_NAME) is null);
Parses source, caches its symbols and compares the the cache content with the results.
Params: source = The source code to test. results = An array of string array. Each slot represents the variable name followed by the type strings.
ModuleCache cache = ModuleCache(theAllocator); writeln("Running alias this tests..."); auto source = q{ struct A {int f;} struct B { A a; alias a this; void fun() { auto var = f; };} }; auto pair = generateAutocompleteTrees(source, cache); auto A = pair.symbol.getFirstPartNamed(internString("A")); auto B = pair.symbol.getFirstPartNamed(internString("B")); auto Af = A.getFirstPartNamed(internString("f")); auto fun = B.getFirstPartNamed(internString("fun")); auto var = fun.getFirstPartNamed(internString("var")); assert(Af is pair.scope_.getFirstSymbolByNameAndCursor(internString("f"), var.location));
Parses source, caches its symbols and compares the the cache content with the results.
Params: source = The source code to test. results = An array of string array. Each slot represents the variable name followed by the type strings.
ModuleCache cache = ModuleCache(theAllocator); writeln("Running `super` tests..."); auto source = q{ class A {} class B : A {} }; auto pair = generateAutocompleteTrees(source, cache); assert(pair.symbol); auto A = pair.symbol.getFirstPartNamed(internString("A")); auto B = pair.symbol.getFirstPartNamed(internString("B")); auto scopeA = (pair.scope_.getScopeByCursor(A.location + A.name.length)); auto scopeB = (pair.scope_.getScopeByCursor(B.location + B.name.length)); assert(scopeA !is scopeB); assert(!scopeA.getSymbolsByName(SUPER_SYMBOL_NAME).length); assert(scopeB.getSymbolsByName(SUPER_SYMBOL_NAME)[0].type is A);
Parses source, caches its symbols and compares the the cache content with the results.