-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonValueTests.cs
More file actions
47 lines (39 loc) · 1.21 KB
/
Copy pathPythonValueTests.cs
File metadata and controls
47 lines (39 loc) · 1.21 KB
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
using System.Globalization;
using System.Numerics;
using DotPython.Runtime.Managed.Execution;
using Xunit;
namespace DotPython.RuntimeTests;
public sealed class PythonValueTests
{
[Theory]
[InlineData(-5)]
[InlineData(0)]
[InlineData(256)]
public void WholeNumberFactory_ReusesValuesInsideTheCache(int value)
{
var first = PythonWholeNumberValue.Create(value);
var second = PythonWholeNumberValue.Create(value);
Assert.Same(first, second);
Assert.Equal(new BigInteger(value), first.Value);
}
[Theory]
[InlineData(-6)]
[InlineData(257)]
public void WholeNumberFactory_DoesNotRetainValuesOutsideTheCache(int value)
{
var first = PythonWholeNumberValue.Create(value);
var second = PythonWholeNumberValue.Create(value);
Assert.NotSame(first, second);
Assert.Equal(first, second);
}
[Fact]
public void WholeNumberFactory_PreservesArbitrarySizeValues()
{
var value = BigInteger.Parse(
"1234567890123456789012345678901234567890",
CultureInfo.InvariantCulture
);
var result = PythonWholeNumberValue.Create(value);
Assert.Equal(value, result.Value);
}
}