Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fast_world_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle committed Oct 19, 2023
2 parents c8f5c86 + 3f33a54 commit ccb606e
Show file tree
Hide file tree
Showing 98 changed files with 2,254 additions and 1,031 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/compiler-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ jobs:
- name: Build
run: dotnet build main/OpenDream.sln --configuration Release --no-restore /m
- name: Compile TestGame
run: main\DMCompiler\bin\Release\net7.0\DMCompiler.exe main\TestGame\environment.dme
run: main\bin\DMCompiler\DMCompiler.exe main\TestGame\environment.dme
- name: Checkout Modified /tg/station
uses: actions/checkout@v2
with:
repository: wixoaGit/tgstation
path: tg
- name: Compile Modified /tg/station
run: main\DMCompiler\bin\Release\net7.0\DMCompiler.exe tg\tgstation.dme
run: main\bin\DMCompiler\DMCompiler.exe tg\tgstation.dme
- name: Checkout 64-bit Paradise
uses: actions/checkout@v2
with:
repository: ike709/Paradise
ref: rustg_64
path: para
- name: Compile 64-bit Paradise
run: main\DMCompiler\bin\Release\net7.0\DMCompiler.exe para\paradise.dme
run: main\bin\DMCompiler\DMCompiler.exe para\paradise.dme
17 changes: 0 additions & 17 deletions Content.Tests/DMProject/Broken Tests/Stdlib/issaved.dm

This file was deleted.

56 changes: 56 additions & 0 deletions Content.Tests/DMProject/Tests/Expression/const_eval.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/datum
var/composite_expr = 4 * sin(3 + cos(2))
var/sintest = sin(45)
var/costest = cos(123)
var/tantest = tan(123)
var/sqrttest = sqrt(123)
var/arcsintest = arcsin(sin(45))
var/arccostest = arccos(cos(123))
var/arctantest = arctan(tan(69))
var/log_test = log(10)
var/log10_test = log(10, 100)
var/arctan2_test = arctan(1, 3)
var/abs_test = abs(-213)

#define EPSILON 4e-6
#define APX_EQUAL(a, b) ASSERT(abs(a - b) < EPSILON)

/proc/RunTest()
var/break_const_eval = null
var/datum/d = new /datum

APX_EQUAL(initial(d.composite_expr), 4 * sin(3 + cos(break_const_eval || 2)))
APX_EQUAL(d.composite_expr, 4 * sin(3 + cos(break_const_eval || 2)))

APX_EQUAL(d.sintest, sin(break_const_eval || 45))
APX_EQUAL(d.sintest, 0.707106769084930419921875)

APX_EQUAL(d.costest, cos(break_const_eval || 123))
APX_EQUAL(d.costest, -0.544639050960540771484375)

APX_EQUAL(d.tantest, tan(break_const_eval || 123))
APX_EQUAL(d.tantest, -1.539865016937255859375)

APX_EQUAL(d.sqrttest, sqrt(break_const_eval || 123))
APX_EQUAL(d.sqrttest, 11.0905361175537109375)

APX_EQUAL(d.arcsintest, arcsin(sin(break_const_eval || 45)))
APX_EQUAL(d.arcsintest, 45)

APX_EQUAL(d.arccostest, arccos(cos(break_const_eval || 123)))
APX_EQUAL(d.arccostest, 123)

APX_EQUAL(d.arctantest, arctan(tan(break_const_eval || 69)))
APX_EQUAL(d.arctantest, 69)

APX_EQUAL(d.log_test, log(break_const_eval || 10))
APX_EQUAL(d.log_test, 2.302585124969482421875)

APX_EQUAL(d.log10_test, log(break_const_eval || 10, 100))
APX_EQUAL(d.log10_test, 2)

APX_EQUAL(d.arctan2_test, arctan(break_const_eval || 1, 3))
APX_EQUAL(d.arctan2_test, 71.5650482177734375)

APX_EQUAL(d.abs_test, abs(break_const_eval || -213))

3 changes: 0 additions & 3 deletions Content.Tests/DMProject/Tests/Math/Addition.dm

This file was deleted.

131 changes: 131 additions & 0 deletions Content.Tests/DMProject/Tests/Operators/Addition.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include "Shared/operator_testing.dm"

/proc/add(a, b)
return a + b

/proc/RunTest()
var/list/expected = list(
20,
"Error",
10,
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"ABCABC",
"ABC",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"ABC/datum/proc",
"ABC/datum/verb",
10,
"ABC",
null,
'Shared/file.txt',
list("A"),
operator_test_object,
/datum,
/datum/proc/foo,
/datum/verb/bar,
/datum/proc,
/datum/verb,
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
list("A", 10),
list("A", "ABC"),
list("A", null),
list("A", 'Shared/file.txt'),
list("A", "A"),
list("A", operator_test_object),
list("A", /datum),
list("A", /datum/proc/foo),
list("A", /datum/verb/bar),
list("A", /datum/proc),
list("A", /datum/verb),
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"/datum/procABC",
"/datum/proc",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"/datum/proc/datum/proc",
"/datum/proc/datum/verb",
"Error",
"/datum/verbABC",
"/datum/verb",
"Error",
"Error",
"Error",
"Error",
"Error",
"Error",
"/datum/verb/datum/proc",
"/datum/verb/datum/verb"
)

test_operator(/proc/add, expected)
1 change: 1 addition & 0 deletions Content.Tests/DMProject/Tests/Operators/Shared/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Used in operator_testing.dm
37 changes: 37 additions & 0 deletions Content.Tests/DMProject/Tests/Operators/Shared/operator_testing.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// IGNORE

// A helper method for testing operators against many kinds of values

/var/datum/operator_test_object = new /datum()

/datum/proc/foo()
/datum/verb/bar()

/proc/test_operator(var/operator_proc, var/list/expected)
var/list/values = list(
10,
"ABC",
null,
'file.txt',
list("A"),
operator_test_object,
/datum,
/datum/proc/foo,
/datum/verb/bar,
/datum/proc,
/datum/verb
)

var/i = 1
for (var/a in values)
for (var/b in values)
var/expected_result = expected[i++]
var/result

try
result = call(operator_proc)(a, b)
catch
result = "Error"

if (result ~! expected_result)
CRASH("Expected [json_encode(expected_result)] for [json_encode(a)] and [json_encode(b)], instead got [json_encode(result)]")
10 changes: 10 additions & 0 deletions Content.Tests/DMProject/Tests/Preprocessor/Pragma/warning_quote.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#define CONDITION_TRUE

#ifdef CONDITION_TRUE
#warn Oh no you're gonna have a bad time
#endif

/proc/RunTest()
return

#warn end of file
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// !issaved(B) commented out because of TODO in DMOpcodeHandlers.IsSaved

/obj/o
var/A
//var/tmp/B
var/tmp/B

/obj/o/proc/IsSavedSrcVars()
ASSERT(issaved(A))
//ASSERT(!issaved(B))
ASSERT(!issaved(B))
ASSERT(issaved(vars["A"]))
//ASSERT(!issaved(vars["B"]))
ASSERT(!issaved(vars["B"]))

/proc/RunTest()
var/obj/o/test = new
ASSERT(!issaved(test.type))
ASSERT(issaved(test.A))
//ASSERT(!issaved(test.B))
ASSERT(!issaved(test.B))

// Note that this doesn't work on most lists and will instead return false
ASSERT(issaved(test.vars["A"]))
//ASSERT(!issaved(test.vars["B"]))
ASSERT(!issaved(test.vars["B"]))

/*
var/expected = prob(50)
Expand Down
7 changes: 4 additions & 3 deletions Content.Tests/DummyDreamMapManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using OpenDreamRuntime;
using OpenDreamRuntime.Objects;
using OpenDreamRuntime.Objects.Types;
Expand All @@ -17,9 +18,9 @@ public void Initialize() { }

public void UpdateTiles() { }

public void LoadAreasAndTurfs(DreamMapJson map) { }
public void LoadMaps(List<DreamMapJson>? maps) { }

public void InitializeAtoms(DreamMapJson map) { }
public void InitializeAtoms(List<DreamMapJson>? maps) { }

public void SetTurf(DreamObjectTurf turf, DreamObjectDefinition type, DreamProcArguments creationArguments) { }

Expand Down
17 changes: 14 additions & 3 deletions DMCompiler/Bytecode/DreamProcOpcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public enum DreamProcOpcode : byte {
PushGlobalVars = 0x5F,
ModulusModulus = 0x60,
ModulusModulusReference = 0x61,
PushProcStub = 0x62,
PushVerbStub = 0x63,
//0x62
//0x63
JumpIfNull = 0x64,
JumpIfNullNoPop = 0x65,
JumpIfTrueReference = 0x66,
Expand All @@ -127,7 +127,18 @@ public enum DreamProcOpcode : byte {
GetStep = 0x75,
Length = 0x76,
GetDir = 0x77,
DebuggerBreakpoint = 0x78
DebuggerBreakpoint = 0x78,
Sin = 0x79,
Cos = 0x7A,
Tan = 0x7B,
ArcSin = 0x7C,
ArcCos = 0x7D,
ArcTan = 0x7E,
ArcTan2 = 0x7F,
Sqrt = 0x80,
Log = 0x81,
LogE = 0x82,
Abs = 0x83,
}

/// <summary>
Expand Down
Loading

0 comments on commit ccb606e

Please sign in to comment.