public Task <bool> Start(ILua lua, GetILuaFromLuaStatePointer lua_extructor, ModuleAssemblyLoadContext _) { TaskCompletionSource <bool> taskCompletion = new TaskCompletionSource <bool>(); try { lua.PushAngle(new System.Numerics.Vector3(0)); if (!lua.GetMetaTable(-1)) { throw new GetMetaTableTestException("GetMetaTable returned false"); } lua.GetField(-1, "IsZero"); lua.Push(-3); lua.MCall(1, 1); bool received_bool = lua.GetBool(-1); lua.Pop(3); if (!received_bool) { throw new GetMetaTableTestException("Meta function returned False but must return True"); } taskCompletion.TrySetResult(true); } catch (Exception e) { taskCompletion.TrySetException(new Exception[] { e }); } return(taskCompletion.Task); }
public Task <bool> Start(ILua lua, GetILuaFromLuaStatePointer lua_extructor, ModuleAssemblyLoadContext _) { TaskCompletionSource <bool> taskCompletion = new TaskCompletionSource <bool>(); try { Random rand = new Random(); string field_id = Guid.NewGuid().ToString(); float x = (float)rand.NextDouble() + rand.Next(-100, 101); float y = (float)rand.NextDouble() + rand.Next(-100, 101); float z = (float)rand.NextDouble() + rand.Next(-100, 101); lua.PushSpecial(SPECIAL_TABLES.SPECIAL_GLOB); lua.PushAngle(new Vector3(x, y, z)); lua.SetField(-2, field_id); lua.GetField(-1, field_id); Vector3 recieved_vec = lua.GetAngle(-1); lua.Pop(2); if (recieved_vec != new Vector3(x, y, z)) { throw new PushAngleException(recieved_vec, new Vector3(x, y, z)); } taskCompletion.TrySetResult(true); } catch (Exception e) { taskCompletion.TrySetException(new Exception[] { e }); } return(taskCompletion.Task); }
public Task <bool> Start(ILua lua, GetILuaFromLuaStatePointer lua_extructor, ModuleAssemblyLoadContext _) { try { Random rand = new Random(); int curr_type; string curr_name; lua.PushNumber(rand.NextDouble()); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.NUMBER || curr_name != "number") { throw new CheckTypeException("number"); } lua.Pop(1); lua.PushString(Guid.NewGuid().ToString()); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.STRING || curr_name != "string") { throw new CheckTypeException("string"); } lua.Pop(1); lua.PushBool(true); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.BOOL || curr_name != "bool") { throw new CheckTypeException("bool"); } lua.Pop(1); lua.PushNil(); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.NIL || curr_name != "nil") { throw new CheckTypeException("nil"); } lua.Pop(1); lua.PushSpecial(SPECIAL_TABLES.SPECIAL_GLOB); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.TABLE || curr_name != "table") { throw new CheckTypeException("table"); } lua.Pop(1); lua.PushVector(new Vector3((float)rand.NextDouble())); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.Vector || curr_name != "vector") { throw new CheckTypeException("vector"); } lua.Pop(1); lua.PushAngle(new Vector3((float)rand.NextDouble())); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.ANGLE || curr_name != "angle") { throw new CheckTypeException("angle"); } lua.Pop(1); lua.PushManagedFunction(this.test_func); curr_type = lua.GetType(-1); curr_name = lua.GetTypeName(curr_type); if (curr_type != (int)TYPES.FUNCTION || curr_name != "function") { throw new CheckTypeException("function"); } lua.Pop(1); taskCompletion.TrySetResult(true); } catch (Exception e) { taskCompletion.TrySetException(new Exception[] { e }); } return(taskCompletion.Task); }