Code Monkey home page Code Monkey logo

code-cop's People

Contributors

vocksel avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

code-cop's Issues

Handle module caching in a Team Create friendly way

As detailed in the Caveats section of the README, support for a team environment is currently very poor. We need a better system for importing modules that will not interfere with other users.

One proposed by einstienK on the devforums looks incredibly promising and should be exactly what we need:

local function assertf(c,m,...)
	if c then return end
	error(m:format(...),0)
end

local loading,ERR = {},{}
local function customRequire(mod)
	local cached = loading[mod]
	while cached == false do wait() cached = loading[mod] end
	assertf(cached ~= ERR,"Error while loading module")
	if cached then return cached end
	local s,e = loadstring(mod.Source)
	assertf(s,"Parsing error for %s: %s", mod:GetFullName(), tostring(e))
	loading[mod] = false
	local env = setmetatable({
		script = mod;
		require = customRequire;
	},{__index=getfenv()})
	s,e = pcall(setfenv(s,env))
	if not s then loading[mod] = ERR end
	assertf(s,"Running error for %s: %s", mod:GetFullName(), tostring(e))
	loading[mod] = e return e
end

customRequire(firstModule)

It's just a matter of implementing this now. I have other projects to worry about right now but this is a top priority when I get back to working on Code Cop. (If anyone else stumbles upon this and wants to give it a shot tho, feel free)

Once implemented we can also delete the Caveats section as it only applies to this issue.

Testing for Failures

Nice plugin! However, sometimes it is useful to write a test that we expect to fail (e.g., verify that certain inputs yield an error). I tried to wrap the invocation of my uut in a pcall, and assert that it returns false, but it looks like the pcall in the plugins TestCase script still interprets the call as a failure.

I was going to modify my local plugin to allow the passing of a flag to indicate an expected failure, and to invert the built-in assertion following the pcall to the callback, but wanted to post an issue first, in case there is already a built-in and recommended way of doing this.

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.