Loading ...
Sorry, an error occurred while loading the content.

Re: [jslint] Re: optionally allow with?

Expand Messages
  • Dan McNeil
    Woops... this is what that last missive was RE: ________________________________ From: walfisch_in_the_sea To:
    Message 1 of 6 , Jan 23, 2010
    • 0 Attachment
      Woops... this is what that last missive was RE:

      From: walfisch_in_the_sea <christian.wirkus@...>
      To: jslint_com@yahoogroups.com
      Sent: Sat, January 23, 2010 11:58:32 AM
      Subject: [jslint] Re: optionally allow with?

      You inspired me to do that today:
      http://github. com/Walfisch/ boring-assert/

      A Javascript test framework that uses chaining,
      the code to use looks like that then (without with and without "o."):

      assert(!!document. body, "document.body should exist").

      print(!!document. body, "document.body should exist").
      print(!document. body, "document.body shall not exist");

      suite("Suite 1", function () {
      assert.print( typeof alert === "function", "alert is function");
      suite("Suite 2", function () {
      print(0.1 + 0.2 === 0.3, "0.1 + 0.2 === 0.3").
      print(0.5 - 0.2 === 0.3, "0.5 - 0.2 === 0.3");

      --- In jslint_com@yahoogro ups.com, "smparkes@.. ." <smparkes@.. .> wrote:
      > Note that I'm not with'ing any of my own objects, I'm withing the test framework itself, and only that. Actually, I have a couple of them that I might with.
      > The difference is the DSL-ish-ness of the result:
      > (function(){
      > with(jasmine) {
      > describe("my type",function( ){
      > it("should do the right thing",function( ){
      > expect("something" ).toBe(true) ;
      > });
      > });
      > };
      > }());
      > Adding a bunch of "o."s in there bugs ... but that's personal and I'm not trying to convince anyone of that. Most test frameworks just bash the global scope, which I don't like either. I could var up all the functions at the top of the closure, so the ugliness is just in one place, but there are too many functions to duplicate all that code.
      > Or I could just have jasmine export a string with all the var statements, and then eval that. jslint won't like that, but it does provide a setting where I can say it's okay to eval in this file.
      > Of course, you can't just var up the functions since they might need closures to get the proper object binding when called that way.
      > All I'm suggesting is that there be a similar switch for with ...
      > ... which I just realized, is actually not implemented at all, so it can't actually be turned off. Hmmm ... maybe I'll implement it for myself.
      > So far, I don't see any particularly big drawbacks to this one use case and the result is significantly prettier to me ...

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.