aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/sputnik_converted/15_Native/15.2_Object_Objects/15.2.4_Properties_of_the_Object_Prototype_Object/15.2.4.6_Object.prototype.isPrototypeOf/S15.2.4.6_A1.js
blob: 46e41ff2aa34d95379852e06f286860aa954a943 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @name: S15.2.4.6_A1;
 * @section: 15.2.4.6;
 * @assertion: When the isPrototypeOf method is called with argument V and when O and 
 * V refer to the same object or to objects joined to each other, return true;
 * @description: Creating two objects with the same prototype;
*/



// Converted for Test262 from original Sputnik source

ES5Harness.registerTest( {
id: "S15.2.4.6_A1",

path: "TestCases/15_Native/15.2_Object_Objects/15.2.4_Properties_of_the_Object_Prototype_Object/15.2.4.6_Object.prototype.isPrototypeOf/S15.2.4.6_A1.js",

assertion: "When the isPrototypeOf method is called with argument V and when O and",

description: "Creating two objects with the same prototype",

test: function testcase() {
   function USER_FACTORY( name ) {
  this.name = name;
  this.getName=function(){return name;};
}


function FORCEDUSER_FACTORY( name, grade ) {
    this.name = name;
  this.grade = grade;
  this.getGrade=function(){return grade;};
}

var proto = new USER_FACTORY("noname");

FORCEDUSER_FACTORY.prototype = proto;

var luke = new FORCEDUSER_FACTORY("Luke Skywalker", 12);
//////
// CHECK#1
if(proto.isPrototypeOf(luke)){
  $PRINT('#1: Native ECMAScript objects have an internal property called [[Prototype]].');
} else {
  $ERROR('#1: native ECMAScript objects have an internal property called [[Prototype]].');
}
//
/////////
//////
// CHECK#2
if(USER_FACTORY.prototype.isPrototypeOf(luke)){
  $PRINT('#2: Native ECMAScript objects have an internal property called [[Prototype]].');
} else {
  $ERROR('#2: native ECMAScript objects have an internal property called [[Prototype]].');
}
//
/////////
//////
// CHECK#3
if(Number.isPrototypeOf(luke)){
  $ERROR('#2: Native ECMAScript objects have an internal property called [[Prototype]].');
}
//
/////////

 }
});