joo.classLoader.prepare(/*
 * Copyright 2008 CoreMedia AG
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an "AS
 * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 * express or implied. See the License for the specific language 
 * governing permissions and limitations under the License.
 */

"package package1", [""],

"public class TestBind",function(TestBind,$$private){with(TestBind)with($$private)return[ 

  "public function TestBind",function $TestBind(state/* : String*/) {this[$super]();
    this[$state] = state;
  },

  "public function getState",function getState()/* : String*/ {
    return this[$state];
  },

  "public bound function getState1",function getState1()/* : String*/ {
    return this[$state];
  },

  "public bound function getState2",function getState2()/* : String*/ {
    return this[$state];
  },

  "public bound function getState3",function getState3()/* : String*/ {
    return this[$state];
  },

  "public bound function getState4",function getState4()/* : String*/ {
    return this[$state];
  },

  // will be auto-bound!
  "private bound function getStatePrivate",function getStatePrivate()/* : String*/ {
    return this[$state];
  },

  "public function testInvokeLocalVar",function testInvokeLocalVar()/* : **/ {
    var f/* : Function*/ = this.getState1;
    return f();
  },

  "public function testInvokeLocalVarUnqualified",function testInvokeLocalVarUnqualified()/* : **/ {
    var f/* : Function*/ = this.getState2;
    return f();
  },

  "public function testInvokeParameter",function testInvokeParameter()/* : String*/ {
    return this[$invoke](this.getState3);
  },

  "public function testInvokeParameterUnqualified",function testInvokeParameterUnqualified()/* : String*/ {
    return this[$invoke](this.getState4);
  },

  "public function testInvokeParameterUnqualifiedPrivate",function testInvokeParameterUnqualifiedPrivate()/* : String*/ {
    return this[$invoke](this[$getStatePrivate]);
  },

  "public function testLocalFunction",function testLocalFunction()/* : String*/ {
    return this[$invoke](function package1$TestBind$72_19() {
      return this.getState();
    }.bind(this));
  },

  "public function testLocalFunctionUnqualified",function testLocalFunctionUnqualified()/* : String*/ {
    return this[$invoke](function package1$TestBind$78_19() {
      return this.getState();
    }.bind(this));
  },

  // negative tests>
  // This method is never actually called, but only analzyed by the compiler.
  // These expressions must *not* lead to testNotBound being bound!
  "public function testDelete",function testDelete()/* : String*/ {
    delete this.testNotBound;
    return typeof this.testNotBound;
  },

  // negative test: testNotBound must not be bound!
  "public function testNotBound",function testNotBound()/* : String*/ {
    return this.getState();
  },

  // negative test: functions using "this" inside static code must not be bound:
  "public static function testStaticNotBound",function testStaticNotBound()/* : String*/ {
    return function package1$TestBind$98_12()/* : Object*/ {
      return this;
    };
  },

  "private function invoke",function invoke(f/* : Function*/)/* : **/ {
    return f();
  },

  "private var",{ state/* : String*/: undefined},
];},["testStaticNotBound"]
);