blob: ff58548a838fb5320323128e8ee3426b1495529b (
plain)
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
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
using System;
using System.Runtime.CompilerServices;
public class Point
{
int x;
int y;
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public Point(int a, int b) { x=a; y = b; }
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public bool IsOrigin() { return (x==0 && y == 0); }
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public int DistanceSquared(Point p) { return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y); }
}
public class BringUpTest
{
const int Pass = 100;
const int Fail = -1;
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static Point ObjAlloc()
{
Point p1 = new Point(10,20);
Point p2 = new Point(10,20);
int d = p1.DistanceSquared(p2);
if (d != 0) return null;
return new Point(0,0);
}
public static int Main()
{
Point obj = ObjAlloc();
if (obj == null) return Fail;
return Pass;
}
}
|