Skip to main content
dulajun
Inspiring
April 20, 2013
Question

What is the meaning of _unitTest at the end of all of sdk samples of Bridge.

  • April 20, 2013
  • 1 reply
  • 633 views

Please could any one help me of the meaning of _unitTest in this snippet of code:

if(typeof(SnpAddMenuItem_unitTest ) == "undefined") {

          new SnpAddMenuItem().run();

}

Thanks in advance.

This topic has been closed for replies.

1 reply

Inspiring
April 20, 2013

I find the sample snipptes a little odd… My take on this is SnpAddMenuItem_unitTest is just a namespace to run the code… If it's undefined then it's not been run against Bridge's script engine before in this session… If you run the samples once they work and return true to the ESTK console… Try again and…

Error:Menu element already exists!

Restart Bridge to run this snippet again.

Result: false

dulajun
dulajunAuthor
Inspiring
April 22, 2013

Thanks, but

Correct me if I'm misunderstand you.

If you include this file more than once -for example twice- in the same session then the "if" condition (typeof(SnpAddMenuItem_unitTest ) will be executed twice:

- in the first time the variable SnpAddMenuItem_unitTest will be defined as public but after the the "==" operation, so it will be undefined and the "if" block will be executed.

- in the second time the variable will be defined already and the "if" statement wouldn't be executed.

I don't think that right. But it's the only way that I could grasp.

And about the Error messages they would be written in the console as a result of canRun() function and not the last "if" statement.