Giter Club home page Giter Club logo

Comments (8)

MikeSchulze avatar MikeSchulze commented on July 20, 2024 1

Thanks for submiting this issue, i will have a deeper look to understand the problem.

from gdunit3.

MikeSchulze avatar MikeSchulze commented on July 20, 2024 1

After deeper investigation It seams to be it is not a snake case issue.
The doubler try to extend by class name but the class has no class_name defined.

So i need to deside to extend by existing class_name or class_path

from gdunit3.

afonsolage avatar afonsolage commented on July 20, 2024 1

It's working fine now! Thanks!

from gdunit3.

afonsolage avatar afonsolage commented on July 20, 2024

I made a small and quick fix, but I don't know if it's the best way. Right after the clazz_name definition, on GdUnitMockBuilder.build I've added the following:

	if "_" in clazz_name or clazz_name == clazz_name.to_lower():
		var result = PoolStringArray()
		var prev_is_underscore = false
		for ch in clazz_name:
			if ch=='_':
				prev_is_underscore = true
			else:
				if prev_is_underscore:
					result.append(ch.to_upper())
				else:
					result.append(ch)
				prev_is_underscore = false

		result[0] = result[0].to_upper()
		clazz_name = result.join('')

The logic I got from here. It is working fine for my tests cases.

from gdunit3.

MikeSchulze avatar MikeSchulze commented on July 20, 2024

@afonsolage you can alternative use the class name to mock the class instead by path.

mock(main_player)

It needs onyl to add the class name definition in your class

class_name main_player

The fix is now in master and you can mock by class path or name as you want.

from gdunit3.

afonsolage avatar afonsolage commented on July 20, 2024

I'll try it, before even using the class_name (which was in PascalCase - MainPlayer) didn't worked, but I'll give a try and post here.

from gdunit3.

afonsolage avatar afonsolage commented on July 20, 2024

It worked for main_class.gd, but not for mob.gd, since mob.gd is snake_case but doesn't have underscore. Something like that would fix:

	# handle snake_case class names, only if clazz path available and is a GdScript
	if "_" in clazz_name and not clazz_path.empty() and (clazz_path[0].find(".gd") != -1):
		return "'%s'" % clazz_path[0]
	elif not ClassDB.class_exists(clazz_name):
		return "'%s'" % clazz_path[0]
	return clazz_name

Add a new test case using a lowercaseonly.gd test file and you should get the problem

from gdunit3.

MikeSchulze avatar MikeSchulze commented on July 20, 2024

pushed new fix to master

from gdunit3.

Related Issues (20)

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.