Skip to content
Browse files

Updated pseudo-test files

  • Loading branch information...
1 parent a3ae046 commit 4342b3a9bae0e5c7cc09b6c52e2a0ca7d87fff3b Rubén Medellín committed
Showing with 71 additions and 47 deletions.
  1. +1 −0 test/browser.html
  2. +70 −0 test/neon_test.js
  3. +0 −47 test/node.js
View
1 test/browser.html
@@ -3,6 +3,7 @@
<head>
<title>Neon</title>
<script src="../neon.js" type="text/javascript"></script>
+ <script src="neon_test.js" type="text/javascript"></script>
</head>
<body>
<h1>Neon</h1>
View
70 test/neon_test.js
@@ -0,0 +1,70 @@
+if(typeof require !== 'undefined') { // We are in Node, need to require the file
+
+ console.log("Requiring neon from file");
+ var Neon = require('../neon.js');
+ console.log(Neon);
+
+ // In Coffeescript, the following construct is recommended
+ // { Class, Module, Interface } = require('neon')
+
+ var Class = Neon.Class;
+ var Module = Neon.Module;
+ var Interface = Neon.Interface;
+}
+
+
+console.log('Class :', typeof Class);
+console.log('Module :', typeof Module);
+console.log('Interface :', typeof Interface);
+
+Module('Composition')({
+ moduleClassVariable : 1,
+ prototype : {
+ moduleInstanceVariable : 2
+ }
+});
+
+Interface('Contract')({
+ constructor : ['ensuredClassVariable'],
+ prototype : ['ensuredInstanceVariable']
+});
+
+Class('BaseClass')({
+ baseClassVariable : 3,
+ prototype : {
+ baseInstanceVariable : 4
+ }
+});
+
+var AnonymousModule = Module()({
+ anonymousClassVariable : 5,
+ prototype : {
+ anonymousInstanceVariable : 6
+ }
+});
+
+Class('MyClass').inherits(BaseClass).ensures(Contract).includes(Composition, AnonymousModule)({
+ GREETING : 'HELLO',
+ inheritedClassVariable : 7,
+ ensuredClassVariable : 8,
+ prototype : {
+ inheritedInstanceVariable : 9,
+ ensuredInstanceVariable : 10,
+ init : function(argument) {
+ console.log(this.constructor.GREETING + ' ' + argument + '!');
+ }
+ }
+});
+
+var instance = new MyClass('world');
+console.log(MyClass.moduleClassVariable);
+console.log(instance.moduleInstanceVariable);
+console.log(MyClass.baseClassVariable);
+console.log(instance.baseInstanceVariable);
+console.log(MyClass.anonymousClassVariable);
+console.log(instance.anonymousInstanceVariable);
+console.log(MyClass.inheritedClassVariable);
+console.log(MyClass.ensuredClassVariable);
+console.log(instance.inheritedInstanceVariable);
+console.log(instance.ensuredInstanceVariable);
+
View
47 test/node.js
@@ -1,47 +0,0 @@
-var Neon = require('../neon.js');
-
-console.log(Neon);
-
-console.log('Neon Class :',typeof Neon.Class);
-console.log('Neon Module :',typeof Neon.Module);
-console.log('Neon Interface :',typeof Neon.Interface);
-
-var Class = Neon.Class;
-var Module = Neon.Module;
-var Interface = Neon.Interface;
-
-console.log('Class :',typeof Class);
-console.log('Module :',typeof Module);
-console.log('Interface :',typeof Interface);
-
-Module('Composition')({
- y : 5,
- prototype : {
- z : 3
- }
-});
-
-Interface('Editable')({
- constructor : ['x'],
- prototype : ['x']
-});
-
-Class('Widget')({
-
-});
-
-Class('Overlay').inherits(Widget).ensures(Editable).includes(Composition)({
- html : '<div></div>',
- x : 10,
- prototype : {
- init : function (element){
- if(!element){
- element = document.createElement('div');
- element.innerHTML = 'hola';
- document.body.appendChild(element);
- }
- },
- x : 10,
- b : 5
- }
-});

0 comments on commit 4342b3a

Please sign in to comment.
Something went wrong with that request. Please try again.