Code refactoring using the new DynamicMethod<T> type
このコミットが含まれているのは:
1 親
2b310aba25
コミット
52ba3183e6
3ファイル変更
+86
-75
検索条件に一致するファイルはありません
@@ -1,4 +1,5 @@
|
||||
using System.Reflection.Emit;
|
||||
using System;
|
||||
using System.Reflection.Emit;
|
||||
using ComputeSharp.Shaders.Extensions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
@@ -8,8 +9,25 @@ namespace ComputeSharp.Tests.Internals
|
||||
[TestCategory("DynamicMethod")]
|
||||
public class DynamicMethodTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestFunc()
|
||||
{
|
||||
Func<int, int> square = DynamicMethod<Func<int, int>>.New(il =>
|
||||
{
|
||||
il.Emit(OpCodes.Ldarg_0);
|
||||
il.Emit(OpCodes.Dup);
|
||||
il.Emit(OpCodes.Mul);
|
||||
il.Emit(OpCodes.Ret);
|
||||
});
|
||||
|
||||
int result = square(2); // result = 2 * 2
|
||||
|
||||
Assert.IsTrue(result == 4);
|
||||
}
|
||||
|
||||
public delegate int Square(int x);
|
||||
|
||||
[TestMethod]
|
||||
public void TestSquare()
|
||||
{
|
||||
Square square = DynamicMethod<Square>.New(il =>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする