1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00
This commit is contained in:
HolonProduction
2024-03-01 12:01:14 +01:00
parent 1f42455e0a
commit a2e7c64dc4
13 changed files with 3 additions and 126 deletions

View File

@@ -31,9 +31,6 @@
#ifndef TEST_COMPLETION_H
#define TEST_COMPLETION_H
#include "core/io/resource.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_uid.h"
#ifdef TOOLS_ENABLED
#include "core/io/config_file.h"
@@ -116,8 +113,6 @@ static void test_directory(const String &p_dir) {
// Require pointer sentinel char in scripts.
CHECK(code.find_char(0xFFFF) != -1);
print_line("Testing completion for: ", next);
ConfigFile conf;
if (conf.load(path.path_join(next.get_basename() + ".cfg")) != OK) {
FAIL("No config file found.");
@@ -143,19 +138,7 @@ static void test_directory(const String &p_dir) {
bool forced;
Node *owner = nullptr;
print_line("before owner load");
if (conf.has_section_key("input", "scene")) {
/*List<String> deps;
ResourceLoader::get_dependencies(conf.get_value("input", "scene"), &deps);
for (const String &E : deps) {
print_line(E);
print_line(ResourceLoader::exists(E));
print_line(ResourceLoader::get_resource_type(E));
Ref<GDScript> s = ResourceLoader::load(E);
if (s->is_valid()) {
print_line(s->get_members().size());
}
}*/
Ref<PackedScene> scene = ResourceLoader::load(conf.get_value("input", "scene"), "PackedScene", ResourceFormatLoader::CACHE_MODE_IGNORE_DEEP);
if (scene.is_valid()) {
owner = scene->instantiate();
@@ -166,16 +149,10 @@ static void test_directory(const String &p_dir) {
owner = scene->instantiate();
}
}
print_line("after owner load");
if (owner != nullptr) {
print_line("owner", owner->to_string());
} else {
print_line("no owner");
}
GDScriptLanguage::get_singleton()->complete_code(code, path.path_join(next), owner, &options, forced, call_hint);
String contains_excluded;
for (ScriptLanguage::CodeCompletionOption &option : options) {
//print_line(option.display);
for (const Dictionary &E : exclude) {
if (match_option(E, option)) {
contains_excluded = option.display;
@@ -189,18 +166,11 @@ static void test_directory(const String &p_dir) {
for (const Dictionary &E : include) {
if (match_option(E, option)) {
include.erase(E);
print_line("erased");
break;
}
}
}
CHECK_MESSAGE(contains_excluded.is_empty(), "Autocompletion suggests illegal option '", contains_excluded, "' for '", path.path_join(next), "'.");
if (!include.is_empty()) {
for (const Dictionary &E : include) {
print_line(E);
}
}
CHECK(include.is_empty());
String expected_call_hint = conf.get_value("output", "call_hint", call_hint);
@@ -219,8 +189,6 @@ static void test_directory(const String &p_dir) {
TEST_SUITE("[Modules][GDScript][Completion]") {
TEST_CASE("[Editor] Check suggestion list") {
ResourceUID::initialize_class();
// Set all editor settings that code completion relies on.
EditorSettings::get_singleton()->set_setting("text_editor/completion/use_single_quotes", false);
init_language("modules/gdscript/tests/scripts");