forked from praeclarum/CLanguage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignTests.cs
85 lines (79 loc) · 1.35 KB
/
AssignTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Linq;
using CLanguage.Interpreter;
using CLanguage.Syntax;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static CLanguage.CLanguageService;
namespace CLanguage.Tests
{
[TestClass]
public class AssignTests : TestsBase
{
[TestMethod]
public void GlobalAssignBits ()
{
Run (@"
int x = 0;
void main() {
x |= 0xCC;
x &= 0xF0;
x ^= 0xFF;
assertAreEqual(63, x);
}
");
}
[TestMethod]
public void GlobalAssignDoubles ()
{
Run (@"
double x = 0.0;
void main() {
x += 100;
x -= 50;
x /= 10;
x *= 1000000.0;
assertDoublesAreEqual(5000000.0, x);
}
");
}
[TestMethod]
public void GlobalAssignLogic ()
{
Run (@"
bool x = false;
void main() {
x ||= true;
x &&= true;
assertBoolsAreEqual(true, x);
}
");
}
[TestMethod]
public void GlobalAssign ()
{
Run (@"
int x = 0;
void main() {
x = 1234;
assertAreEqual(1234, x);
}
");
}
[TestMethod]
public void GlobalAfterArray ()
{
Run (@"
int a[] = {111, 222};
int x = 0;
void main() {
x = 1234;
int i = 0;
for (i = 0; i < 10; i++) {
}
assertAreEqual(1234, x);
assertAreEqual(10, i);
}
");
}
}
}